9

When a customer visits a product page, the order quantity is standard set to 0. I want it to be automatically set to 1, but I have no clue how to do this. How do you do this?

[1]

Translation: Normale prijs = Normal price; Aantal = Amount/Quantity; Aan winkelwagen toevoegen = Add to cart

Thanks in advance.

  • How about your current issue there? – Khoa TruongDinh Sep 22 '16 at 15:18
  • 1
    What do you mean with current issue? If you mean I forgot to accept the answer: I'm sorry 😁, I've accepted your answer now. – Kevin Sep 22 '16 at 21:16
22

--The easiest way is that we can change the input value from template: (override this template - not recommend)
vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml

--The second way is the Magento default config: STORES > Configuration > Catalog > Inventory > Product Stock Options > Minimum Qty Allowed in Shopping Cart > > Add Customer Group > change to 1

  • 1
    Thanks, second way did the trick. (Haven't tried the first way.) – Kevin Sep 15 '16 at 17:12
  • 1
    The second way should be preferred :-) – Alex May 15 '17 at 10:26
  • 2
    I would say the second method is also the easiest, wouldn't even mention the first – Holly Jul 14 '17 at 14:08
4

Khoa's second option is the preferred one. Anyways, this sometimes does not work for bundles. There you have to also carefully check the bundles option's and quantities.

The logic for the default quantity could be found in

\Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option::getDefaultValues

In my case a required option did not have a default option, leading to a zero default quantity.

1

--The second way is the Magento default config: STORES > Configuration > Catalog > Inventory > Product Stock Options > Minimum Qty Allowed in Shopping Cart > > Add Customer Group > change to 1

For some clarity on this question if the above doesn't work:

This was already done on the site I was working on, the issue was that on the individual product (in my case a configurable parent) under CATALOG > Products > PRODUCT > Advanced Inventory > Minimum Qty Allowed in Shopping Cart was set to NOT use this default config: enter image description here

Changing this to Use Config Settings: enter image description here

Changes the default qty to be 1 on the frontend:

enter image description here

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.