Magento quantity increment/decrement problem












0















I used Increment & Decrement qty in Shopping Cart page



<div class="qty-ctl">    
<button title="Decrease Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',0); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>

<div class="qty-ctl">
<button title="Increase Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',1); return false;" class="increase"><?php echo $this->__('increase') ?></button>
</div>


it's working fine while increment one by one if i type 5 and press enter it automaticall reduce 1 product it shows 4 only. What is the problem



<script type="text/javascript">
function changeQty(id,increase) {
var qty = parseInt($(id).value);
if ( !isNaN(qty) ) {
qty = increase ? qty+1 : (qty>1 ? qty-1 : 1);
$(id).value = qty;
document.getElementById("scart").submit();
}
}
</script>









share|improve this question
















bumped to the homepage by Community 44 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Post your changeQty function here

    – Akhilesh Patel
    Jan 13 '16 at 11:15











  • Check my updated question

    – user31402
    Jan 13 '16 at 11:19
















0















I used Increment & Decrement qty in Shopping Cart page



<div class="qty-ctl">    
<button title="Decrease Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',0); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>

<div class="qty-ctl">
<button title="Increase Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',1); return false;" class="increase"><?php echo $this->__('increase') ?></button>
</div>


it's working fine while increment one by one if i type 5 and press enter it automaticall reduce 1 product it shows 4 only. What is the problem



<script type="text/javascript">
function changeQty(id,increase) {
var qty = parseInt($(id).value);
if ( !isNaN(qty) ) {
qty = increase ? qty+1 : (qty>1 ? qty-1 : 1);
$(id).value = qty;
document.getElementById("scart").submit();
}
}
</script>









share|improve this question
















bumped to the homepage by Community 44 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Post your changeQty function here

    – Akhilesh Patel
    Jan 13 '16 at 11:15











  • Check my updated question

    – user31402
    Jan 13 '16 at 11:19














0












0








0








I used Increment & Decrement qty in Shopping Cart page



<div class="qty-ctl">    
<button title="Decrease Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',0); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>

<div class="qty-ctl">
<button title="Increase Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',1); return false;" class="increase"><?php echo $this->__('increase') ?></button>
</div>


it's working fine while increment one by one if i type 5 and press enter it automaticall reduce 1 product it shows 4 only. What is the problem



<script type="text/javascript">
function changeQty(id,increase) {
var qty = parseInt($(id).value);
if ( !isNaN(qty) ) {
qty = increase ? qty+1 : (qty>1 ? qty-1 : 1);
$(id).value = qty;
document.getElementById("scart").submit();
}
}
</script>









share|improve this question
















I used Increment & Decrement qty in Shopping Cart page



<div class="qty-ctl">    
<button title="Decrease Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',0); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>

<div class="qty-ctl">
<button title="Increase Qty" onclick="changeQty('<?php echo 'qty_'.$_item->getId() ?>',1); return false;" class="increase"><?php echo $this->__('increase') ?></button>
</div>


it's working fine while increment one by one if i type 5 and press enter it automaticall reduce 1 product it shows 4 only. What is the problem



<script type="text/javascript">
function changeQty(id,increase) {
var qty = parseInt($(id).value);
if ( !isNaN(qty) ) {
qty = increase ? qty+1 : (qty>1 ? qty-1 : 1);
$(id).value = qty;
document.getElementById("scart").submit();
}
}
</script>






magento-1.9






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 13 '16 at 11:47

























asked Jan 13 '16 at 10:32







user31402












bumped to the homepage by Community 44 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 44 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Post your changeQty function here

    – Akhilesh Patel
    Jan 13 '16 at 11:15











  • Check my updated question

    – user31402
    Jan 13 '16 at 11:19



















  • Post your changeQty function here

    – Akhilesh Patel
    Jan 13 '16 at 11:15











  • Check my updated question

    – user31402
    Jan 13 '16 at 11:19

















Post your changeQty function here

– Akhilesh Patel
Jan 13 '16 at 11:15





Post your changeQty function here

– Akhilesh Patel
Jan 13 '16 at 11:15













Check my updated question

– user31402
Jan 13 '16 at 11:19





Check my updated question

– user31402
Jan 13 '16 at 11:19










2 Answers
2






active

oldest

votes


















0














Try this code



<input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" id="cart[<?php echo $_item->getId() ?>][qty]"/>

<div class="qty-ctl">
<button title="Increase Qty" onclick="changeQty( <?php echo $_item->getId() ?>, 1 ); return false;" class="increase"><?php echo $this->__('increase') ?></button>
<button title="Decrease Qty" onclick="changeQty( <?php echo $_item->getId() ?>, -1 ); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>
</div>
<script type="text/javascript">
function changeQty(id, num) {
var qty_id = "cart[" + id + "][qty]";
var currentVal = parseInt($(qty_id).value);
if (currentVal != NaN)
{
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if(keyCode != 13) {
$(qty_id).value = currentVal + num;
}
document.getElementById("scart").submit();
}
}

</script>





share|improve this answer


























  • what is size="4"

    – user31402
    Jan 13 '16 at 11:43











  • Sorry check my updated question

    – user31402
    Jan 13 '16 at 11:48













  • I copied it from my setup. you can remove size attribute

    – Akhilesh Patel
    Jan 13 '16 at 11:57











  • Please check my updated question that's exact script

    – user31402
    Jan 13 '16 at 11:58











  • edited my script. try it

    – Akhilesh Patel
    Jan 13 '16 at 12:05



















0














You can also try this:



<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Basket'); ?>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
<?php if(!$_product->isGrouped()): ?>
<label for="qty"><?php echo $this->__('QUANTITY') ?></label>
<div class="quantity"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></div>
<?php endif; ?>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><i class="fa fa-caret-right"></i> <?php echo $buttonTitle ?></span><span id="ajax_loader" style="display:none;"><i class="fa fa-spinner fa-spin"></i></span></button>
<?php echo $this->getChildHtml('', true, true) ?>
</div>
<?php endif; ?>
<script>
jQuery(document).ready(function($) {
// Add to cart + and -
jQuery("div.quantity").prepend('<i id="qtyplus" class="fa fa-angle-up plus"></i>').append('<i id="qtyminus" class="fa fa-angle-down minus"></i>');
jQuery("#qtyplus").click(function() {
var currentVal = parseInt(jQuery(this).next(".qty").val());
if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
jQuery(this).next(".qty").val(currentVal + 1);
});
jQuery("#qtyminus").click(function() {
var currentVal = parseInt(jQuery(this).prev(".qty").val());
if (currentVal == "NaN") currentVal = 1;
if (currentVal > 1) {
jQuery(this).prev(".qty").val(currentVal - 1);
}
});
});
</script>


(remember I'm using fontawesome icons for + and - which you can replace)






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f97012%2fmagento-quantity-increment-decrement-problem%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown
























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try this code



    <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" id="cart[<?php echo $_item->getId() ?>][qty]"/>

    <div class="qty-ctl">
    <button title="Increase Qty" onclick="changeQty( <?php echo $_item->getId() ?>, 1 ); return false;" class="increase"><?php echo $this->__('increase') ?></button>
    <button title="Decrease Qty" onclick="changeQty( <?php echo $_item->getId() ?>, -1 ); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>
    </div>
    <script type="text/javascript">
    function changeQty(id, num) {
    var qty_id = "cart[" + id + "][qty]";
    var currentVal = parseInt($(qty_id).value);
    if (currentVal != NaN)
    {
    if (!e) e = window.event;
    var keyCode = e.keyCode || e.which;
    if(keyCode != 13) {
    $(qty_id).value = currentVal + num;
    }
    document.getElementById("scart").submit();
    }
    }

    </script>





    share|improve this answer


























    • what is size="4"

      – user31402
      Jan 13 '16 at 11:43











    • Sorry check my updated question

      – user31402
      Jan 13 '16 at 11:48













    • I copied it from my setup. you can remove size attribute

      – Akhilesh Patel
      Jan 13 '16 at 11:57











    • Please check my updated question that's exact script

      – user31402
      Jan 13 '16 at 11:58











    • edited my script. try it

      – Akhilesh Patel
      Jan 13 '16 at 12:05
















    0














    Try this code



    <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" id="cart[<?php echo $_item->getId() ?>][qty]"/>

    <div class="qty-ctl">
    <button title="Increase Qty" onclick="changeQty( <?php echo $_item->getId() ?>, 1 ); return false;" class="increase"><?php echo $this->__('increase') ?></button>
    <button title="Decrease Qty" onclick="changeQty( <?php echo $_item->getId() ?>, -1 ); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>
    </div>
    <script type="text/javascript">
    function changeQty(id, num) {
    var qty_id = "cart[" + id + "][qty]";
    var currentVal = parseInt($(qty_id).value);
    if (currentVal != NaN)
    {
    if (!e) e = window.event;
    var keyCode = e.keyCode || e.which;
    if(keyCode != 13) {
    $(qty_id).value = currentVal + num;
    }
    document.getElementById("scart").submit();
    }
    }

    </script>





    share|improve this answer


























    • what is size="4"

      – user31402
      Jan 13 '16 at 11:43











    • Sorry check my updated question

      – user31402
      Jan 13 '16 at 11:48













    • I copied it from my setup. you can remove size attribute

      – Akhilesh Patel
      Jan 13 '16 at 11:57











    • Please check my updated question that's exact script

      – user31402
      Jan 13 '16 at 11:58











    • edited my script. try it

      – Akhilesh Patel
      Jan 13 '16 at 12:05














    0












    0








    0







    Try this code



    <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" id="cart[<?php echo $_item->getId() ?>][qty]"/>

    <div class="qty-ctl">
    <button title="Increase Qty" onclick="changeQty( <?php echo $_item->getId() ?>, 1 ); return false;" class="increase"><?php echo $this->__('increase') ?></button>
    <button title="Decrease Qty" onclick="changeQty( <?php echo $_item->getId() ?>, -1 ); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>
    </div>
    <script type="text/javascript">
    function changeQty(id, num) {
    var qty_id = "cart[" + id + "][qty]";
    var currentVal = parseInt($(qty_id).value);
    if (currentVal != NaN)
    {
    if (!e) e = window.event;
    var keyCode = e.keyCode || e.which;
    if(keyCode != 13) {
    $(qty_id).value = currentVal + num;
    }
    document.getElementById("scart").submit();
    }
    }

    </script>





    share|improve this answer















    Try this code



    <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" id="cart[<?php echo $_item->getId() ?>][qty]"/>

    <div class="qty-ctl">
    <button title="Increase Qty" onclick="changeQty( <?php echo $_item->getId() ?>, 1 ); return false;" class="increase"><?php echo $this->__('increase') ?></button>
    <button title="Decrease Qty" onclick="changeQty( <?php echo $_item->getId() ?>, -1 ); return false;" class="decrease"><?php echo $this->__('decrease') ?></button>
    </div>
    <script type="text/javascript">
    function changeQty(id, num) {
    var qty_id = "cart[" + id + "][qty]";
    var currentVal = parseInt($(qty_id).value);
    if (currentVal != NaN)
    {
    if (!e) e = window.event;
    var keyCode = e.keyCode || e.which;
    if(keyCode != 13) {
    $(qty_id).value = currentVal + num;
    }
    document.getElementById("scart").submit();
    }
    }

    </script>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 13 '16 at 12:05

























    answered Jan 13 '16 at 11:41









    Akhilesh PatelAkhilesh Patel

    4,13921229




    4,13921229













    • what is size="4"

      – user31402
      Jan 13 '16 at 11:43











    • Sorry check my updated question

      – user31402
      Jan 13 '16 at 11:48













    • I copied it from my setup. you can remove size attribute

      – Akhilesh Patel
      Jan 13 '16 at 11:57











    • Please check my updated question that's exact script

      – user31402
      Jan 13 '16 at 11:58











    • edited my script. try it

      – Akhilesh Patel
      Jan 13 '16 at 12:05



















    • what is size="4"

      – user31402
      Jan 13 '16 at 11:43











    • Sorry check my updated question

      – user31402
      Jan 13 '16 at 11:48













    • I copied it from my setup. you can remove size attribute

      – Akhilesh Patel
      Jan 13 '16 at 11:57











    • Please check my updated question that's exact script

      – user31402
      Jan 13 '16 at 11:58











    • edited my script. try it

      – Akhilesh Patel
      Jan 13 '16 at 12:05

















    what is size="4"

    – user31402
    Jan 13 '16 at 11:43





    what is size="4"

    – user31402
    Jan 13 '16 at 11:43













    Sorry check my updated question

    – user31402
    Jan 13 '16 at 11:48







    Sorry check my updated question

    – user31402
    Jan 13 '16 at 11:48















    I copied it from my setup. you can remove size attribute

    – Akhilesh Patel
    Jan 13 '16 at 11:57





    I copied it from my setup. you can remove size attribute

    – Akhilesh Patel
    Jan 13 '16 at 11:57













    Please check my updated question that's exact script

    – user31402
    Jan 13 '16 at 11:58





    Please check my updated question that's exact script

    – user31402
    Jan 13 '16 at 11:58













    edited my script. try it

    – Akhilesh Patel
    Jan 13 '16 at 12:05





    edited my script. try it

    – Akhilesh Patel
    Jan 13 '16 at 12:05













    0














    You can also try this:



    <?php $_product = $this->getProduct(); ?>
    <?php $buttonTitle = $this->__('Add to Basket'); ?>
    <?php if($_product->isSaleable()): ?>
    <div class="add-to-cart">
    <?php if(!$_product->isGrouped()): ?>
    <label for="qty"><?php echo $this->__('QUANTITY') ?></label>
    <div class="quantity"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></div>
    <?php endif; ?>
    <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><i class="fa fa-caret-right"></i> <?php echo $buttonTitle ?></span><span id="ajax_loader" style="display:none;"><i class="fa fa-spinner fa-spin"></i></span></button>
    <?php echo $this->getChildHtml('', true, true) ?>
    </div>
    <?php endif; ?>
    <script>
    jQuery(document).ready(function($) {
    // Add to cart + and -
    jQuery("div.quantity").prepend('<i id="qtyplus" class="fa fa-angle-up plus"></i>').append('<i id="qtyminus" class="fa fa-angle-down minus"></i>');
    jQuery("#qtyplus").click(function() {
    var currentVal = parseInt(jQuery(this).next(".qty").val());
    if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
    jQuery(this).next(".qty").val(currentVal + 1);
    });
    jQuery("#qtyminus").click(function() {
    var currentVal = parseInt(jQuery(this).prev(".qty").val());
    if (currentVal == "NaN") currentVal = 1;
    if (currentVal > 1) {
    jQuery(this).prev(".qty").val(currentVal - 1);
    }
    });
    });
    </script>


    (remember I'm using fontawesome icons for + and - which you can replace)






    share|improve this answer




























      0














      You can also try this:



      <?php $_product = $this->getProduct(); ?>
      <?php $buttonTitle = $this->__('Add to Basket'); ?>
      <?php if($_product->isSaleable()): ?>
      <div class="add-to-cart">
      <?php if(!$_product->isGrouped()): ?>
      <label for="qty"><?php echo $this->__('QUANTITY') ?></label>
      <div class="quantity"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></div>
      <?php endif; ?>
      <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><i class="fa fa-caret-right"></i> <?php echo $buttonTitle ?></span><span id="ajax_loader" style="display:none;"><i class="fa fa-spinner fa-spin"></i></span></button>
      <?php echo $this->getChildHtml('', true, true) ?>
      </div>
      <?php endif; ?>
      <script>
      jQuery(document).ready(function($) {
      // Add to cart + and -
      jQuery("div.quantity").prepend('<i id="qtyplus" class="fa fa-angle-up plus"></i>').append('<i id="qtyminus" class="fa fa-angle-down minus"></i>');
      jQuery("#qtyplus").click(function() {
      var currentVal = parseInt(jQuery(this).next(".qty").val());
      if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
      jQuery(this).next(".qty").val(currentVal + 1);
      });
      jQuery("#qtyminus").click(function() {
      var currentVal = parseInt(jQuery(this).prev(".qty").val());
      if (currentVal == "NaN") currentVal = 1;
      if (currentVal > 1) {
      jQuery(this).prev(".qty").val(currentVal - 1);
      }
      });
      });
      </script>


      (remember I'm using fontawesome icons for + and - which you can replace)






      share|improve this answer


























        0












        0








        0







        You can also try this:



        <?php $_product = $this->getProduct(); ?>
        <?php $buttonTitle = $this->__('Add to Basket'); ?>
        <?php if($_product->isSaleable()): ?>
        <div class="add-to-cart">
        <?php if(!$_product->isGrouped()): ?>
        <label for="qty"><?php echo $this->__('QUANTITY') ?></label>
        <div class="quantity"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></div>
        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><i class="fa fa-caret-right"></i> <?php echo $buttonTitle ?></span><span id="ajax_loader" style="display:none;"><i class="fa fa-spinner fa-spin"></i></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>
        </div>
        <?php endif; ?>
        <script>
        jQuery(document).ready(function($) {
        // Add to cart + and -
        jQuery("div.quantity").prepend('<i id="qtyplus" class="fa fa-angle-up plus"></i>').append('<i id="qtyminus" class="fa fa-angle-down minus"></i>');
        jQuery("#qtyplus").click(function() {
        var currentVal = parseInt(jQuery(this).next(".qty").val());
        if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
        jQuery(this).next(".qty").val(currentVal + 1);
        });
        jQuery("#qtyminus").click(function() {
        var currentVal = parseInt(jQuery(this).prev(".qty").val());
        if (currentVal == "NaN") currentVal = 1;
        if (currentVal > 1) {
        jQuery(this).prev(".qty").val(currentVal - 1);
        }
        });
        });
        </script>


        (remember I'm using fontawesome icons for + and - which you can replace)






        share|improve this answer













        You can also try this:



        <?php $_product = $this->getProduct(); ?>
        <?php $buttonTitle = $this->__('Add to Basket'); ?>
        <?php if($_product->isSaleable()): ?>
        <div class="add-to-cart">
        <?php if(!$_product->isGrouped()): ?>
        <label for="qty"><?php echo $this->__('QUANTITY') ?></label>
        <div class="quantity"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></div>
        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><i class="fa fa-caret-right"></i> <?php echo $buttonTitle ?></span><span id="ajax_loader" style="display:none;"><i class="fa fa-spinner fa-spin"></i></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>
        </div>
        <?php endif; ?>
        <script>
        jQuery(document).ready(function($) {
        // Add to cart + and -
        jQuery("div.quantity").prepend('<i id="qtyplus" class="fa fa-angle-up plus"></i>').append('<i id="qtyminus" class="fa fa-angle-down minus"></i>');
        jQuery("#qtyplus").click(function() {
        var currentVal = parseInt(jQuery(this).next(".qty").val());
        if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;
        jQuery(this).next(".qty").val(currentVal + 1);
        });
        jQuery("#qtyminus").click(function() {
        var currentVal = parseInt(jQuery(this).prev(".qty").val());
        if (currentVal == "NaN") currentVal = 1;
        if (currentVal > 1) {
        jQuery(this).prev(".qty").val(currentVal - 1);
        }
        });
        });
        </script>


        (remember I'm using fontawesome icons for + and - which you can replace)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 13 '16 at 12:10









        Ahmed ElawadiAhmed Elawadi

        1,438720




        1,438720






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f97012%2fmagento-quantity-increment-decrement-problem%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            What other Star Trek series did the main TNG cast show up in?

            Berlina muro

            Berlina aerponto