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

#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 );