Magento WizardNo joke, this website relaunches on 1st April. New look, new features!

Contact the site  Make Money

Change Default Quantity on Magento Product Page

 Add to Favourites  
(2 rating, 4 votes)
Loading ... Loading ...

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="&lt;?php echo $this-&gt;getMinimalQty($_product) ?&gt;" />

To…

<input id="qty" class="input-text qty" maxlength="12" name="qty" type="text" value="&lt;?php echo $this-&gt;getMinimalQty($_product)== null?1:$this-&gt;getMinimalQty($_product) ?&gt;" />
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

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

 Product Comparison - Video Guide
 Product Page Ratings & Reviews - Video Guide
 Search on Magento - Video Guide
 Product Tags on Product Page - Video Guide
 Image upload failure on Magento Product Page

comments

11 Responses to “Change Default Quantity on Magento Product Page”

  1. Prashant on January 16th, 2009

    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

    <input name=”qty” type=”text” class=”input-text qty” id=”qty” maxlength=12? value=”getMinimalQty($_product)== null?1:$this->getMinimalQty($_product) ?>/>

    Thanks,

  2. Geoffrey on February 1st, 2009

    correct line is :
    <input name=”qty” type=”text” class=”input-text qty” id=”qty” maxlength=”12″ value=”getMinimalQty($_product)==null?1:$this->getMinimalQty($_product) ?>” />

  3. Guillaume on February 27th, 2009

    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.

  4. Irwan on April 7th, 2009

    Thank you, it worked for me!

  5. Kelvin Tong on April 26th, 2009

    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) ?>” />

  6. Jimmy Rabøl Jørgensen on November 10th, 2009

    Hmm Can’t make it work, and i breaks up my design.
    To bad

  7. mike on November 16th, 2009

    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) ?>

  8. mike on November 16th, 2009

    Sorry the code didn’t show up well, not sure whats wrong


    getProduct() ?>

    isSaleable()): ?>
    __('Availability: In stock.') ?>

    __('Availability: Out of stock.') ?>

    getPriceHtml($_product) ?>

  9. mike on November 17th, 2009

    how do you post code?

  10. Kamil P on January 12th, 2010

    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’

  11. Kamil P on January 12th, 2010

    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

Leave a Reply




Spam protection by WP Captcha-Free


Remove Product Tags from Magento Product Page

  • Sponsored Ads

  • Magento Themes
    • vtiger: great article, thank you....
  • Recent Tweets

    Magento Raises $22.5 Million For Open Source E-Commerce Platform http://bit.ly/bIVcah

    @jakobkahlen could be done in an Open source commerce solution like magento.

    Guanabara: 'Magento recebe US$22,5 milhões em injeção de capital' http://oia.la/eQQ

    RT @TechCrunch Magento Scores $22.5 Million For Open Source E-commerce Platform Play http://tcrn.ch/9AVi5I

    Magento Scores $22.5 Million For Open Source E-commerce Platform Play http://redir.ec/LXYd