Wednesday 13 February 2013

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 class="back"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text 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 ?>" class="button btn-cart" 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>

1 comment:

  1. Great blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
    magento development company in bangalore 

    ReplyDelete

Note: only a member of this blog may post a comment.