2

Referring to this question How do I programmatically apply a coupon in Woocommerce?

I'm looking for something very similar to the final solution in the first post, but I'd like the coupon to be applied if the subtotal is > 99 euros.

How do you think I can modify the code? And since I'm a newbie... where do I have to paste the whole code?

Thanks a lot

Community
  • 1
  • 1
Vainucleo
  • 29
  • 2

1 Answers1

0

Something like this could be done:

add_action('woocommerce_before_checkout_process','add_discount_at_checkout');

function add_discount_at_checkout(){
global $woocommerce;
$minorder = 99;
if( $woocommerce->cart->get_cart()->cart_contents_total>$minorder){

 //APPLY COUPON HERE

}
}

So basically, if your cart total is greater than 99, you can do something, like add a coupon.

danyo
  • 5,686
  • 20
  • 59
  • 119