Thursday, January 10, 2013

Set default quantity of product to 1 in magento


By default magento takes quantity value to be "0". To change this you just need to edit addtocart.phtml file located at app/design/frontend/default/[your theme]/template/catalog/product/view/addtocart.phtml


<?php if($_product->isSaleable()): ?>
    <fieldset class="add-to-cart-box">
        <legend><?php echo $this->__('Add Items to Cart') ?></legend>
        <?php if(!$_product->isGrouped()): ?>
        <span class="qty-box"><label for="qty"><?php echo $this->__('Qty') ?>:</label>
        <input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" /></span>
        <?php endif; ?>
        <button class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button>
    </fieldset>
<?php endif; ?>



just change the highlighted section to value="1" and you are done.

No comments:

Post a Comment