Ina Code Blog

bunch of code in one place
« Magento: onepage checkout problem
Magento: Image zoom: set initial zoom »


Dec
17

Magento: Display default Add to cart quantity

Posted by admin in Magento

On product page the add to cart quantity field is empty, but I would like to display quantity value 1 or minimal add to quantity value.

Open file: /app/design/frontend/darila/darila/template/catalog/product/view/addtocart.phtml and find line

<input name=”qty” class=”input-text qty” id=”qty” maxlength=”12″ value=”<?php echo $this->getMinimalQty($_product) ?>” type=”text” />

and replace it with:

<input name=”qty” class=”input-text qty” id=”qty” maxlength=”12″ value=”<?php if($_product->isSaleable()): ?><?php echo $this->getMinimalQty($_product)== null?1:$this->getMinimalQty($_product) ?><?php else: ?><?php echo $this->getMinimalQty($_product)== null?0:$this->getMinimalQty($_product) ?><?php endif; ?>” type=”text” />

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

One Response to “Magento: Display default Add to cart quantity”

  1. Added by zmove on Jun at 10

    Interesting post.

    I’m looking for a way to add the quantity field on the product listing. Do you know how to do that ?

Leave a Reply

Comment