Skip to content
Advertisement

Delete the product in the cart, if the same product added in Woocommerce

There are methods that empty the cart if you add a new product.

JavaScript

But what I want is only if you add the same product. So adding if ( $in_cart ) does the job but I also do not want to empty whole cart.

Just want to delete the same product that added previously and keep the others.

I mean overwrite.

Advertisement

Answer

You can use woocommerce_add_to_cart_validation action hooks and check against products that are already in the cart. code will go in your active theme functions.php file.

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