Change Default Quantity on Magento Product Page
Add to Favourites
|
I find it a tad annoying how on Magento, you’ve got this empty quantity box next to the Buy Now/Add to Basket button. Although clicking the button alone will add an item to the cart, some users may experience doubt in this motion, and enter the quantity required AS WELL as press the button.
But why even have any doubt? Why not just make the default quantity set to 1 – well this something that a lot of people have required, and fortunately, I have got the answer!
In app\design\frontend\default\default\template\catalog\product\view\type\Simple.phtml
Just change…
<input id="qty" class="input-text qty" maxlength="12" name="qty" type="text" value="<?php echo $this->getMinimalQty($_product) ?>" />
To…
<input id="qty" class="input-text qty" maxlength="12" name="qty" type="text" value="<?php echo $this->getMinimalQty($_product)== null?1:$this->getMinimalQty($_product) ?>" />
about the author
This article was written by Sam Davis on November 20, 2008.
Computing over a glass of Grenache Shiraz... again! Sam is the Editor of Blasted Thing. Contact Us |
related articles
comments
11 Responses to “Change Default Quantity on Magento Product Page”
Leave a Reply
![]() Remove Product Tags from Magento Product Page |





























Good Tip, but I think from version 1.1.6 the path of file is different, Now we have to edit the following file
app\design\frontend\default\default\template\catalog\product\view\addtocart.phtml
with the below code
Thanks,
correct line is :
<input name=”qty” type=”text” class=”input-text qty” id=”qty” maxlength=”12″ value=”getMinimalQty($_product)==null?1:$this->getMinimalQty($_product) ?>” />
Hello,
It doesn’t work for me !!
I still have the message:
Fatal error: Call to a member function getStoreId() on a non-object
I hope you could help me.
Thank you, it worked for me!
Thanks for the good script, however to get it work for version 1.3.x, I need to edit to the following.
<input name=”qty” type=”text” class=”input-text qty” id=”qty” maxlength=”12″ value=”getMinimalQty($_product)==null?1:$this->getMinimalQty($_product) ?>” />
Hmm Can’t make it work, and i breaks up my design.
To bad
I tried oppening the file but this is all i got, no input , any tips?
getProduct() ?>
isSaleable()): ?>
__(‘Availability: In stock.’) ?>
__(‘Availability: Out of stock.’) ?>
getPriceHtml($_product) ?>
Sorry the code didn’t show up well, not sure whats wrong
getProduct() ?>
isSaleable()): ?>
__('Availability: In stock.') ?>
__('Availability: Out of stock.') ?>
getPriceHtml($_product) ?>
how do you post code?
Kelving Tong posted correct code, although some php part is missing!
I’ll try to use code tags to insert correct code
Hope that nothing gets ‘eaten’
it didn’t work ;/
anyways just insert opening php tag right after value=” and also add ‘dollar_sign’ echo this-> before getMinimalQty and it should work.
thanks to OP for the code and to others for contributing