I’ve been looking for a solution to disable certain products from the same category if one of the items is added to the cart.
For example: I have 1 category with products from A to E.
If I add product A to the cart I want to disable products B and E, so they can’t be added to the cart during the same shopping session.
Is there a way to achieve this?
Many thanks.
2
Answers
Yes , you actually have two options ,one is to customize your own plugin and insert it to your website but this actually takes time .The other way is to download a wholesale and b2b plugin , these plugins usually contain features as the one you are looking for , so you will be able to activate the feature that you want .
You can do that by validating the cart whenever an item is added to it.
You can do that by editing your theme (or child theme) functions.php file or by using your custom plugin.
You can use the following hook ‘woocommerce_add_to_cart_validation’
PS: I just wrote this code. I didn’t have time to test it yet.
Let me know your feedback.