Thursday, August 11, 2011

How to add Quantity Box in the Category Products Listing Page in magento?

Edit your list.phtml file located at "/app/design/frontend/default/your-theme/template/catalog/product/list.phtml".

Find the below code, line number at 61 for list mode and line number 103 for grid view:
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
replace it with,
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
 <?php if(!$_product->isGrouped()): ?>
     <label for="qty"><?php echo $this->__('Qty') ?>:</label>
     <input type="text" name="qty" id="qty" maxlength="12" size = "3" value="<?php echo ($this->getMinimalQty($_product)?$this->getMinimalQty($_product):1) ?>" />
 <?php endif; ?>
</form>

1 comment: