I would like to disable 'cart needs payment' for a list of discount codes:
- coupon1, coupon2, coupon3, etc..
I have found this code by @LoicTheAztec, and it works fine, but only for a specific discount code:
add_filter( 'woocommerce_cart_needs_payment', 'filter_cart_needs_payment', 10, 2 );
function filter_cart_needs_payment( $needs_payment, $cart ) {
// The targeted coupon code
$targeted_coupon_code = 'coupon1';
if( in_array( $targeted_coupon_code, $cart->get_applied_coupons() ) ) {
$needs_payment = false;
}
return $needs_payment;
}
To disable "cart needs payment" for a list of discount codes, I applied the following modification to the existing code:
$targeted_coupon_code = array('coupon1', 'coupon2', 'coupon3');
Unfortunately without the desired result. Any advice?