• Resolved jaak69

    (@jaak69)


    On my site, I’m using the Woocommerce Dynamic Pricing plugin to provide certain customer group discounts.

    To exclude products on sale I’m using the next filter:

    function is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
        
       remove_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
    
        
       if ( $product->is_on_sale() || <strong>CONDITION FOR GIFT CARD</strong> == true  ) {
            $eligible = false;
        }
        
        add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
    
        return $eligible;
    }

    How to add the condition to exclude Gift cards?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pimwick

    (@pimwick)

    You can test the class type to see if it is a PW Gift Card product:

    if ( is_a( $product, 'WC_Product_PW_Gift_Card' ) ) {

    If that doesn’t work, you might need to check the parent ID instead like this:

    $parent_product_id = $parent->get_parent_id();
    if ( !empty( $parent_product_id ) ) {
        $parent_product = wc_get_product( $parent_product_id );
        if ( is_a( $parent_product, 'WC_Product_PW_Gift_Card' ) ) {
    Plugin Author pimwick

    (@pimwick)

    I’m marking this thread as resolved but let us know if you need further help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PW gift cards and discounts plugin’ is closed to new replies.