Tag : quantity-box

Magento – Show Quantity Box in Products List

In file ‘list.phtml’ file change the <button> line near line 108 from this:


<?php if($_product->isSaleable()): ?>
<button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?<')">>span>
<?php echo $this->__('Add to Cart') ?></span></button>

with:


<form action="
<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId(); ?>">
<input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="
<?php echo $this->getMinimalQty($_product) ?>" />
<button class=form-button" onclick="productAddToCartForm_
<?php echo $_product->getId(); ?>.submit()"><span>
<?php echo $this->__('Add to Cart') ?></span></button>
</form>
<script type="text/javascript">
var productAddToCartForm_
<?php echo $_product->getId(); ?> = new VarienForm('product_addtocart_form_
<?php echo $_product->getId(); ?>');
productAddToCartForm_
<?php echo $_product->getId(); ?>.submit = function(){
if (this.validator.validate()) {
this.form.submit();
}
}.bind(productAddToCartForm_<?php echo $_product->getId(); ?>);
</script>

Read full article