Can any one tell me how to add qty increment and decrement button on order review page in magento 1.9.?
1 Answer
For adding '+' & '-' button on your quantity in magento cart, please Find below code from file -
app\design\frontend[your package][your theme]\template\checkout\cart\item\default.phtml
<input type="text" pattern="\d*" name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" data-cart-item-id="<?php echo $this->jsQuoteEscape($_item->getSku()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Qty')) ?>" class="input-text qty" maxlength="12" />
and replace it with
<a href="#" class="minus-item">-</a>
<input type="text" pattern="\d*" name="cart[<?php echo $_item->getId() ?>][qty]" onchange="$('FORM-ID HERE').submit()" value="<?php echo $this->getQty() ?>" size="4" data-cart-item-id="<?php echo $this->jsQuoteEscape($_item->getSku()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Qty')) ?>" class="input-text qty" maxlength="12" />
<a href="#" class="plus-item">+</a>
add two anchors with a class and increment and decrements signs
NOTE- Please look for the FORM-ID HERE ID on your form Tag.
And add the script to the bottom of your page:
<script type="text/javascript">
$(document).on('click', 'a.minus-item', function(e){
e.preventDefault();
input = $(this).next('input');
newVal = parseInt(input.val())-1;
if(newVal > 0){
input.val(newVal);
$('#FORM-ID HERE').submit();
}
});
$(document).on('click', 'a.plus-item', function(e){
e.preventDefault();
input = $(this).prev('input');
newVal = parseInt(input.val())+1;
if(newVal > 0){
input.val(newVal);
$('#FORM-ID HERE').submit();
}
});
</script>
Hope this will help...!!!
-
-
Locate the file from where its rendering using inspect element and add the same to the file.– Lalit838Commented Oct 3, 2017 at 12:39