Magento Themes and Magento Extensions

Add increment decrement Qty in Cart Magento

Share

Add increment decrement Qty in Cart Magento

app\design\frontend\default\your theme\template\catalog\product\view\addtocart.phtm
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__(‘Add to Cart’); ?>
<?php if($_product->isSaleable()): ?>

<?php if(!$_product->isGrouped()): ?>

<ul>
<li> <a href=”javascript:void(0)” onclick=”decrementQty(‘qty’);”><img src=”<?php echo $this->getSkinUrl(‘images’)?>/plus-icon-1.jpg” alt=”" border=”0″ /></a></li>
<li><input type=”text” name=”qty” id=”qty” maxlength=”12″ value=”<?php echo $this->getProductDefaultQty() * 1 ?>” title=”<?php echo $this->__(‘Qty’) ?>” /></li>
<li><a href=”javascript:void(0);” onclick=”incrementQty(‘qty’);”><img src=”<?php echo $this->getSkinUrl(‘images’)?>/plus-icon-2.jpg” alt=”" border=”0″/></a></li>
</ul>

<?php endif; ?>
<button type=”button” title=”<?php echo $buttonTitle ?>” onclick=”productAddToCartForm.submit(this)”><span><span><?php echo $buttonTitle ?></span></span></button>
<?php echo $this->getChildHtml(”, true, true) ?>

<?php endif; ?>
<script type=”text/javascript”>
//<![CDATA[
function decrementQty(id) {
var val = parseInt($(id).getValue());
if(val != 1)
document.getElementById(id).value = val - 1;
}
function incrementQty(id) {
var val = parseInt($(id).getValue());
document.getElementById(id).value = val + 1;
}
//]]>
</script>

Comments are closed.