Increment and decrement qty button on shopping cart page in magento 1.9
<div class="qty-wrapper">
<label for="qty"><?php echo $this->__('Quantity:') ?></label>
<div class="qty-box">
<?php if(!$_product->isGrouped()): ?>
<a class="minus" id="<?php echo $_product->getId() . "minus" ?>" href="javascript:void(0);">-</a>
<input type="text" readonly="true" name="qty" id="qty<?php echo $_product->getId() ?>" maxlength="12" value="<?php echo ($_product->getStockItem()->getMinSaleQty() ? $_product->getStockItem()->getMinSaleQty() : 1) ?>" />
<a class="plus" id="<?php echo $_product->getId() . "plus" ?>" href="javascript:void(0);">+</a>
<?php endif; ?>
</div>
</div>
----------------------------------------------------
<script type="text/javascript">
$j(document).ready(function() {
$j(".minus").click(function() {
var id = this.id;
var value = $j('#' + id).next('input').val();
var fieldID = $j(this).next('input').attr("id");
if (value > 1) {
value = value - 1;
$j('#' + fieldID).val(value);
}
});
$j(".plus").click(function() {
var id = this.id;
var value = $j('#' + id).prev('input').val();
var fieldID = $j(this).prev('input').attr("id");
++value;
$j('#' + fieldID).val(value);
});
});
</script>
<div class="qty-wrapper">
<label for="qty"><?php echo $this->__('Quantity:') ?></label>
<div class="qty-box">
<?php if(!$_product->isGrouped()): ?>
<a class="minus" id="<?php echo $_product->getId() . "minus" ?>" href="javascript:void(0);">-</a>
<input type="text" readonly="true" name="qty" id="qty<?php echo $_product->getId() ?>" maxlength="12" value="<?php echo ($_product->getStockItem()->getMinSaleQty() ? $_product->getStockItem()->getMinSaleQty() : 1) ?>" />
<a class="plus" id="<?php echo $_product->getId() . "plus" ?>" href="javascript:void(0);">+</a>
<?php endif; ?>
</div>
</div>
----------------------------------------------------
<script type="text/javascript">
$j(document).ready(function() {
$j(".minus").click(function() {
var id = this.id;
var value = $j('#' + id).next('input').val();
var fieldID = $j(this).next('input').attr("id");
if (value > 1) {
value = value - 1;
$j('#' + fieldID).val(value);
}
});
$j(".plus").click(function() {
var id = this.id;
var value = $j('#' + id).prev('input').val();
var fieldID = $j(this).prev('input').attr("id");
++value;
$j('#' + fieldID).val(value);
});
});
</script>
No comments:
Post a Comment