Changing Default Quantity in Magento from 0 to 1
By default, Magento will either display a 0 or leave the quantity field blank on product pages. There are many articles online explaining that to correct this, edit the addtocart.phtml file and change the Magento function getProductDefaultQty
to use the getMinimalQty
instead.
The correct process is to simply define the default quantity in the Magento back office.
System >> Catalog >> Inventory >> Product Stock Options
Then look for ‘Minimum Qty Allowed in Shopping Cart’ and click ‘Add Minimum Qty’ and add a minimum quantity of ‘1’ to the appropriate customer group(s) and then save changes.
Now the default quantity on product pages will be pre-filled with 1 for your customers. With no code change necessary.
Thanks its working fine
Hi. Do you have any idea why this is solution is not working for me in Magento 1.8.1? I modified the code and the back-end as indicated above and can’t seem to get it to work. Appreciate any further insight…
What’s the outcome when you try implementing the above?
Thanx….. I was about to make a mess!!! 🙂
Hah, easily done in Magento Tanmay.
Glad this post helped you out.
I’m using Magento 1.9.1 and it seems to work for some product types. It seems to work for configurable but the simple products are showing a “0”. Any suggestions?
I’d imagine there has been some sort of code change for this in your theme already Anthony if after re-indexing and clearing cache, simple products default to 0 quantity and configurable products default to 1 quantity.
I think this was already handled by default in Magento 1.9.x.
What theme are you using? Are you able to revert to the default Magento theme and test to see if anything changes?
I’m using a theme called Argento Theme (Mall) from argentotheme.com. It has several themes included as well as some extensions built in. I’ll bet there’s something that overwrites that setting. In any case, I’ll try to look into it a bit more. Thank you.
Ah yes, I’m familiar with the theme.
As mentioned, literally the quickest way is to revert to the default Magento theme for two seconds, reload a simple product page/configurable product page and then switch the themes back in the Magento admin.
You can them compare if anything is different between the themes for the default quantity. See how you get on and feel free to leave another comment if you don’t get to the bottom of it.
In app/design/frontend/base/default/template/catalog/product/view/addtocart.phtml the quantity is set to “$this->getProductDefaultQty() * 1”. I can just easily replace that with “$this->__(‘1’)”, however, there’s something causing the default to show as “0”. I don’t know where to look for that function to diagnose it.
Replied to your last comment at the same time as you posted this one. Heh.
Does the theme you are using also have a
addtocart.phtml
template file at the equivalent location?You did set the minimum quantity in the admin for all customer groups didn’t you?
No, the theme doesn’t have addtocart.phtml in the equivalent location. Yes, I did set the minimum quantity for all levels in the configuration. Do you suppose that leaving the value as “$this->__(‘1’)” will be regrettable for any reason down the line?