0

I have a product collection on home page and there I have put increment and decrement buttons.Buttons are working fine, The problem I am currently facing is the updated new quantity is not showing on cart page.

<form action="<?php echo Mage::helper('checkout/cart')->getAddUrl($a); ?>" method="post" id="product_addtocart_form_<?php echo $a->getId() ?>"<?php if ($a->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
                                                    <div class="qty-box">
                                                        <?php if (!$a->isGrouped()): ?>
<!--                                                            <label for="qty"><?php // echo $this->__('Qty')   ?></label>-->
                                                            <a class="minus" id="<?php echo $a->getId() . "minus" ?>" href="javascript:void(0);">-</a>
                                                            <input type="text" name="qty" class="input-text clone-qty" id="qty<?php echo $a->getId() ?>"disabled="true" maxlength="12" value="<?php echo ($a->getStockItem()->getMinSaleQty() ? $a->getStockItem()->getMinSaleQty() : 1) ?>" /> 
                                                            <a class="plus" id="<?php echo $a->getId() . "plus" ?>"  href="javascript:void(0);">+</a>
                                                        <?php endif; ?>
                                                    </div>
                                                    <button type="button" class="btn-cart button" onclick="this.form.submit()"><span><?php echo $this->__('Add') ?></span></button>
                                                </form>

1 Answer 1

0
   <form action="<?php echo Mage::helper('checkout/cart')->getAddUrl($a); ?>" method="post" id="product_addtocart_form_<?php echo $a->getId() ?>"<?php if ($a->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
                                            <div class="qty-box">
                                                <?php if (!$a->isGrouped()): ?>
                                                    <a class="minus" id="<?php echo $a->getId() . "minus" ?>" href="javascript:void(0);">-</a>
                                                    <input type="text" readonly="true" name="qty" id="qty<?php echo $a->getId() ?>" maxlength="12" value="<?php echo ($a->getStockItem()->getMinSaleQty() ? $a->getStockItem()->getMinSaleQty() : 1) ?>" />
                                                    <a class="plus" id="<?php echo $a->getId() . "plus" ?>"  href="javascript:void(0);">+</a>
                                                <?php endif; ?>
                                            </div>
                                            <button type="button" class="btn-cart button" onclick="this.form.submit()"><span><?php echo $this->__('Add') ?></span></button>
                                        </form>






 $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);


                                                    });
                                                });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.