Public snippet   |  Code orientation PHP  |   Tested for Magento version 1.3.2 Use if you want an input box on the category list page, very useful for wholesale-type sites. Replace the existing <button> with this code - the button appears in two places in the list page (one for Grid and one for List)
<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>

Total snippets

158

Who's new

  • Naguripisto
  • Stolenfinche
  • anhreg
  • HamuroGTRx
  • almotaRom
 
Magento Code Snippets by the developers for developers :) | Established & Maintained by Branko Ajzele from ActiveCodeline