1

I am trying to figure out how to set the maximum qty allowed in a shopping cart for an individual product.

In my case: Most products can be added to the cart as many times as they want, but I have a few products, that are configurables that can only be added once to the shopping cart per order.

In my research through the internet I found a few stackoverflow post and articles (below): https://stackoverflow.com/questions/27982651/magento-how-to-set-a-minimum-order-quantity-of-individual-simple-products

http://www.templatemonster.com/help/magento-how-to-set-minimummaximum-quantity-of-products-per-order.html#gref

where in Magento 1.9 you could set the Maximum and Minimum Qty Allowed in Shopping Cart per product. However, I haven't been able to find how to do this in Magento 2, I only found the global configurable.

If there is no way to do it through the admin, how would I go about to do this in code.

3

For Magento 2.1.x

Goto Admin -> Stores -> Configuration enter image description here

For individual settings, go to product details enter image description here

Click Advanced Inventory

enter image description here

  • Hi! How about for configurable product. When I checked advanced inventory for a configurable product detail page i only get to see Manage Stock and Enable Qty Increments. – Noemi Quezada Jul 18 '16 at 16:46
  • In that case you need to go simple product. That means configurable child product details page. – Sohel Rana Jul 18 '16 at 17:02
  • I understand that, however is it possible to also be able to limit the number of configurable products that are added to the cart. Meaning if I have a red shirt that is a configurable product with sizes Small and Large that when I add it to the cart I can only add one Red shirt, no matter the size? Thanks! – Noemi Quezada Jul 18 '16 at 17:08
  • @SohelRana I set 3 in Admin -> store-> Configuration -> catalog -> Inventory -> Product Stock Option -> Maximum Qty Allowed in Shopping Cart but i can add above 3 product to cart , its not working for me. is there any way to do this. – Rajkumar .E Sep 3 '16 at 11:50
1

As mentioned in the answer below, the max qty allowed for a simple product can be controlled through Magento 2 by changing the Maximum Qty Allowed in Shopping Cart in the Advanced Inventory panel at the product level.

However, in my case since I wanted to limit the max number of qty of configurable products I could add to the cart. I know that when a product is added to the cart and is considered to be a configurable, the simple product that expresses the options selected is added to the cart, not the configurable product itself.

For this, I had to create an observer that listened to the checkout_cart_product_add_after event. That way when a new product is attempted to be added to the cart, it will check if the product that is attempted to be added belongs to the configurable product that is only allowed to be added to the cart once, if so error out in this case.

0

You can do this as the other two have answered (using Advanced Inventory) on a configurable product, by looking at the simple products associated with it and changing the "Maximum Qty Allowed in Shopping Cart" for those products too.

0

I have same requirement ,could you please specify how to do this and full path of code if possible, I am newbie in magento 2

  1. How to define maximum number of quantity in entire cart

    2.Set Maximum Purchase Order Amount

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.