Skip to content
Advertisement

Disable shopping when an item from a specific product category is in cart in Woocommerce

I am trying to Disable shopping if a an item from a specific product category is in cart (which is a subscription in form of product with tabs – checkout and shipping are stripped off). When that product is added to cart, no other products should be allowed to be add up.

I have tried those threads code:

But didn’t helped.

How can I disable shopping if a specific product category is in cart on Woocommerce?

output problem image

Advertisement

Answer

October 2018 – Improved updated code version:
Disable other product categories for a cart item from specific category in Woocommerce

Try the following code, that will:

  1. Avoid add to cart when a product from a specific product category is in cart
  2. Remove other cart items when a product from a specific product category is added to cart

The code:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and works.

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