Check if ANY coupon code is applied in woocommerce

Torque2 picture Torque2 · Feb 3, 2016 · Viewed 7k times · Source

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.

Answer

Anand Shah picture Anand Shah · Feb 3, 2016

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";