Skip to content
Advertisement

WooCommerce – Remove item from cart if specific coupon code or product is not present or removed

I have added a function to add a free product when a certain coupon code is entered.

I now need to check if the original product is still in the cart, and if not, remove coupon and free product from the cart.

JavaScript

Advertisement

Answer

You will need another action to check if the coupon was removed.

JavaScript

This should do it – I haven’t tested it.

Source 1: http://hookr.io/actions/woocommerce_removed_coupon/

Source 2: https://businessbloomer.com/woocommerce-remove-product-from-cart-programmatically/

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement