Reputation: 23
When viewing products in the category view, I would like to be able to have a “Quantity” box that allows the user to add and remove quantity needed before clicking the “Add to Cart” button. How can I show this? I am very new to Magento Please help
Upvotes: 1
Views: 3892
Reputation: 1963
Here it is
Go to the app/design/frontend/default/theme-folder/template/catalog/product/list.phtml
find the line
<?php if($_product->isSaleable()): ?><button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
and replace with below
<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>
Upvotes: 4