WooCommerce cart order limit based on product category quantity, weight and different products

admin

Administrator
Staff member
I'm stumped at the moment as I've looked everywhere online as to how to limit the amount of products in your cart based on the quantity of the product category, the total weight of the cart and the amount of different products in the cart for Woocommerce in WordPress. Below are the rules I need to implement that restricts the customer from buying x amount of this, etc.

<ul>
<li>Vitamins: have a limit of 3 for each item <br>I can do this as I have these plugins installed <a href="https://wordpress.org/plugins/woocommerce-incremental-product-quantities/" rel="nofollow noreferrer">WooCommerce Advanced Product Quantities</a> and <a href="https://docs.woothemes.com/document/minmax-quantities/" rel="nofollow noreferrer">Woocommerce Min/Max Quantities</a>. But they can't help me with the others as they don't limit the quantity based on category only per product i.e. Formula Milk, cart max 6 but it allows 6 per product making it 12 if you order 2 products)</li>
<li>Formula Milk: Maximum quantity of 6.</li>
<li>Adult Milk Powder: Maximum quantity of 8.</li>
<li>Wash Supplies: Maximum 3 different items. Total quantity cannot exceed more than 10 pieces and a maximum weight of 3.5kg.</li>
<li>Food: Total quantity cannot exceed more than 18 pieces and a maximum weight of 4kg.</li>
<li>Cosmetic: Cannot exceed a maximum weight of 1kg. A single item has a maximum of 3 pieces</li>
<li><strong>Mixed Items:</strong> In the cart you cannot have more than 7 different items, each item's maximum quantity is 6 pieces. Total quantity cannot exceed more than 12 pieces and a maximum weight of 3.5kg.<br>Lower quantities will stay the same i.e. Vitamins stays at 3, food is limited to 6 from 18, and the total sum of all item quantities in the cart is limited to 12. So you can have as a maximum:

<ul>
<li>Product #1: 1 Food</li>
<li>Product #2: 2 Vitamin #1</li>
<li>Product #3: 3 Vitamin #2</li>
<li>Product #4: 3 Cosmetic #1</li>
<li>Product #5: 1 Cosmetic #2</li>
<li>Product #6: 1 Milk Formula</li>
<li>Product #7: 1 Adult Milk Powder</li>
</ul></li>
<li>Max 7 different products, total quantity of 12 and max weight of 3.5kg. This last rule will override a couple of the other rules.</li>
</ul>

If any of these rules are breached then a wc_notice should show up and state what is wrong, and stop them from adding to cart/proceeding to checkout.

So this is my dilemma, I know how to read the custom jquery when provided but I don't know how I can do this, and my wordpress php knowledge is limited so I don't know how to create actions but can again sort of read and understand it.

Any help is appreciated, if you find a plugin that will do something like this too please let me know. Thanks for your time and sorry about the length of the question.

Kind Regards

--

Edit:

I've thought maybe I can use this code in some way but instead of minimum convert it to maximum.

<a href="https://stackoverflow.com/questions...order-if-cart-contains-some-products-category">Woocommerce: Set minimum Order if Cart contains some Products / Category</a>