Repository Forums Support WooCommerce Extended Coupon Features PRO Excluded Product Option not working

Topic Resolution: Resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3875
    invisiblecodeweaver
    Participant

    I created Percent Cart Discount Coupon of 20%. I wanted this NOT to be used when there is any SALE PRODUCT in the cart or Any other plugin that I placed in Excluded Product Option. Even though I double checked my settings but this coupon is still applicable even when there is a sale product or excluded product in the cart. Please take a look and let me know how this can be fixed

    #3879
    Soft79
    Keymaster

    Unfortunately that’s how the percent discount works. WC used to have a “cart % discount” but removed this in 3.0. I have a snippet somewhere to enable this again, I’ll look it up…

    #3880
    Soft79
    Keymaster
    
    add_filter( 'woocommerce_cart_coupon_types', function ( $coupon_types ) {
    if ( ! in_array( 'percent_cart', $coupon_types ) ) $coupon_types[] = 'percent_cart';
    return $coupon_types;
    }, 10, 1 );
    add_filter( 'woocommerce_coupon_discount_types', function ( $coupon_discount_types ) {
    $coupon_discount_types['percent_cart'] = __( 'Percentage cart discount', 'your-language-domain' );
    $coupon_discount_types['percent'] = __( 'Percentage product discount', 'your-language-domain' );
    return $coupon_discount_types;
    }, 10, 1 );
    add_filter( 'woocommerce_coupon_get_discount_amount', function( $discount_amount, $discounting_amount, $cart_item, $single, $coupon ) {
    if ( $coupon->is_type( 'percent_cart' ) ) {
    $discount = (float) $coupon->get_amount() * ( $discounting_amount / 100 );
    $discount_amount = round( min( $discount, $discounting_amount ), wc_get_rounding_precision() );
    }
    return $discount_amount;
    }, 10, 5 );
    
    #3892
    invisiblecodeweaver
    Participant

    I placed the code in functions.php file and nothing is changed. The coupon still applicable on Sale items and also on excluded products. I could provide you login details so that you can take a look and make necessary changes because I need it to work as soon as possible.

    #3893
    Soft79
    Keymaster

    Did you change the coupons discount type to ‘Percentage cart discount’?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.