Magento 2 - How to set a maximum order qty of individual products?












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.










share|improve this question





























    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.










    share|improve this question



























      1












      1








      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.










      share|improve this question
















      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.







      magento2 shopping-cart quantity cataloginventory






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 23 '17 at 12:37









      Community

      1




      1










      asked Jul 16 '16 at 0:32









      Noemi QuezadaNoemi Quezada

      489729




      489729






















          4 Answers
          4






          active

          oldest

          votes


















          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






          share|improve this answer
























          • 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.






          share|improve this answer































            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.






            share|improve this answer































              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








              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "479"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f125971%2fmagento-2-how-to-set-a-maximum-order-qty-of-individual-products%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                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






                share|improve this answer
























                • 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
















                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






                share|improve this answer
























                • 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














                3












                3








                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






                share|improve this answer













                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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 16 '16 at 2:08









                Sohel RanaSohel Rana

                20.4k34055




                20.4k34055













                • 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



















                • 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

















                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





                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





                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





                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





                @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.






                share|improve this answer




























                  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.






                  share|improve this answer


























                    1












                    1








                    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.






                    share|improve this answer













                    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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 21 '16 at 19:40









                    Noemi QuezadaNoemi Quezada

                    489729




                    489729























                        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.






                        share|improve this answer




























                          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.






                          share|improve this answer


























                            0












                            0








                            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.






                            share|improve this answer













                            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.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Aug 20 '17 at 12:07









                            tim.bakertim.baker

                            553724




                            553724























                                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








                                share|improve this answer




























                                  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








                                  share|improve this answer


























                                    0












                                    0








                                    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








                                    share|improve this answer













                                    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









                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 11 mins ago









                                    insoftserviceinsoftservice

                                    101




                                    101






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Magento Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f125971%2fmagento-2-how-to-set-a-maximum-order-qty-of-individual-products%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Magento 2 controller redirect on button click in phtml file

                                        Polycentropodidae