Reputation: 103
When I apply a fixed amount discount coupon on an order, some products price become 0,
can I prevent this by fixing minimum product price (maybe 0,5)
The cart minimum is 300 and coupon can never be more then 50% of the cart total
Upvotes: 0
Views: 436
Reputation: 103
After handred of tests and research i found a solution
function filter_woocommerce_coupon_get_discount_amount( $discounting_amount, $price_to_discount , $cart_item, $single, $coupon ) {
// On backorder
if ( $cart_item['data']->get_price() - $discounting_amount <= 0 ) {
$discounting_amount = 0;
}
return $discounting_amount;
}
add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 );
Upvotes: 0