Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if ANY coupon code is applied in woocommerce

How do I check if ANY coupon is applied to a product in woocommerce at checkout?

Everything I see checks for ID or slug, or an array of them, but I want to adjust some fields at checkout based on whether or not there's a coupon, any coupon.

Thanks in advance.

like image 225
Torque2 Avatar asked Dec 14 '22 08:12

Torque2


1 Answers

If you want to check for a specific coupon, @Reigel's answer is the solution. However to check if ANY coupon has been applied the following code will get the job done.

if( WC()->cart->get_coupons() ) echo "Coupon applied";
like image 170
Anand Shah Avatar answered Jan 02 '23 08:01

Anand Shah