Allow only a single top-level category of items in the cart
-
Hi everybody, I need to do something like in topic. When cart is empty, the chosen item is added. But adding second item and another needs control (it should be added only when its top-level category agrees with the category of the first item). So I need to block adding to cart in some cases with message in <p class=”woocommerce-error”> on the cart page, I’m redirected to.
I’m a beginner in WordPress. I’m able to write php function getting the top-level category of a product (e.g. by its id). But I don’t know what hook should I use, when hooks are activated, how everything is connected and so on.
Help me please (sorry for my English, it’s not my mother tongue).
- The topic ‘Allow only a single top-level category of items in the cart’ is closed to new replies.