Quantity Increment and Decrement Button not work in Magento 2Magento 1.8 order product quantity per 0.1 decimalsProduct QTY Increment Magento 1.8shopping cart page increment and decrement buttonIncrement and decrement qty button on shopping cart pageProduct quantity incremet/decrement on home pageQuantity increment buttonquantity increment button based on _qtyIncrements valueMagento 2 product list quantity increment buttonsQuantity increment validation failurehow to add quantity increment and decreament (+ and - button) in minicart magento 2?

Am I eligible for the Eurail Youth pass? I am 27.5 years old

Turning a hard to access nut?

What (if any) is the reason to buy in small local stores?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Deletion of copy-ctor & copy-assignment - public, private or protected?

Do I need to consider instance restrictions when showing a language is in P?

PTIJ What is the inyan of the Konami code in Uncle Moishy's song?

두음법칙 - When did North and South diverge in pronunciation of initial ㄹ?

Why are there no stars visible in cislunar space?

Is it insecure to send a password in a `curl` command?

What exactly term 'companion plants' means?

How do hiring committees for research positions view getting "scooped"?

Bash - pair each line of file

What is the relationship between relativity and the Doppler effect?

When did antialiasing start being available?

Relation between independence and correlation of uniform random variables

I got the following comment from a reputed math journal. What does it mean?

Can a medieval gyroplane be built?

Variable completely messes up echoed string

Using Past-Perfect interchangeably with the Past Continuous

What does "Four-F." mean?

Pronounciation of the combination "st" in spanish accents

Are dual Irish/British citizens bound by the 90/180 day rule when travelling in the EU after Brexit?

In Aliens, how many people were on LV-426 before the Marines arrived​?



Quantity Increment and Decrement Button not work in Magento 2


Magento 1.8 order product quantity per 0.1 decimalsProduct QTY Increment Magento 1.8shopping cart page increment and decrement buttonIncrement and decrement qty button on shopping cart pageProduct quantity incremet/decrement on home pageQuantity increment buttonquantity increment button based on _qtyIncrements valueMagento 2 product list quantity increment buttonsQuantity increment validation failurehow to add quantity increment and decreament (+ and - button) in minicart magento 2?













1















I'm using custom modules to show quantity increment/decrement in quantity box
using KnockoutJS.



Making custom modules for every folder is correct.but it nothing happpend, after click on increment/decrement button on product details page in magentov2.1.9.



I followed this link during this task:



https://magenticians.com/quantity-increment-decrement-magento-2/



what are missing from my side.



enter image description here










share|improve this question
























  • How can we help you? Can you post what kind of error you receive or code you have written?

    – Bartosz Herba
    Nov 15 '17 at 7:11











  • @BartoszHerba, I mentioned above link to follows.but in my case script not work in this task.hope you understand.

    – Anikesh Shahi
    Nov 15 '17 at 7:17











  • Great to have documentation of module but how i am suppose to guess what is wrong with YOUR code if you are not sharing it nor the error logs?

    – Bartosz Herba
    Nov 15 '17 at 7:22















1















I'm using custom modules to show quantity increment/decrement in quantity box
using KnockoutJS.



Making custom modules for every folder is correct.but it nothing happpend, after click on increment/decrement button on product details page in magentov2.1.9.



I followed this link during this task:



https://magenticians.com/quantity-increment-decrement-magento-2/



what are missing from my side.



enter image description here










share|improve this question
























  • How can we help you? Can you post what kind of error you receive or code you have written?

    – Bartosz Herba
    Nov 15 '17 at 7:11











  • @BartoszHerba, I mentioned above link to follows.but in my case script not work in this task.hope you understand.

    – Anikesh Shahi
    Nov 15 '17 at 7:17











  • Great to have documentation of module but how i am suppose to guess what is wrong with YOUR code if you are not sharing it nor the error logs?

    – Bartosz Herba
    Nov 15 '17 at 7:22













1












1








1








I'm using custom modules to show quantity increment/decrement in quantity box
using KnockoutJS.



Making custom modules for every folder is correct.but it nothing happpend, after click on increment/decrement button on product details page in magentov2.1.9.



I followed this link during this task:



https://magenticians.com/quantity-increment-decrement-magento-2/



what are missing from my side.



enter image description here










share|improve this question
















I'm using custom modules to show quantity increment/decrement in quantity box
using KnockoutJS.



Making custom modules for every folder is correct.but it nothing happpend, after click on increment/decrement button on product details page in magentov2.1.9.



I followed this link during this task:



https://magenticians.com/quantity-increment-decrement-magento-2/



what are missing from my side.



enter image description here







quantity magento-2.1.9 qty-increment






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 11 mins ago









Teja Bhagavan Kollepara

3,00641949




3,00641949










asked Nov 15 '17 at 6:03









Anikesh ShahiAnikesh Shahi

152215




152215












  • How can we help you? Can you post what kind of error you receive or code you have written?

    – Bartosz Herba
    Nov 15 '17 at 7:11











  • @BartoszHerba, I mentioned above link to follows.but in my case script not work in this task.hope you understand.

    – Anikesh Shahi
    Nov 15 '17 at 7:17











  • Great to have documentation of module but how i am suppose to guess what is wrong with YOUR code if you are not sharing it nor the error logs?

    – Bartosz Herba
    Nov 15 '17 at 7:22

















  • How can we help you? Can you post what kind of error you receive or code you have written?

    – Bartosz Herba
    Nov 15 '17 at 7:11











  • @BartoszHerba, I mentioned above link to follows.but in my case script not work in this task.hope you understand.

    – Anikesh Shahi
    Nov 15 '17 at 7:17











  • Great to have documentation of module but how i am suppose to guess what is wrong with YOUR code if you are not sharing it nor the error logs?

    – Bartosz Herba
    Nov 15 '17 at 7:22
















How can we help you? Can you post what kind of error you receive or code you have written?

– Bartosz Herba
Nov 15 '17 at 7:11





How can we help you? Can you post what kind of error you receive or code you have written?

– Bartosz Herba
Nov 15 '17 at 7:11













@BartoszHerba, I mentioned above link to follows.but in my case script not work in this task.hope you understand.

– Anikesh Shahi
Nov 15 '17 at 7:17





@BartoszHerba, I mentioned above link to follows.but in my case script not work in this task.hope you understand.

– Anikesh Shahi
Nov 15 '17 at 7:17













Great to have documentation of module but how i am suppose to guess what is wrong with YOUR code if you are not sharing it nor the error logs?

– Bartosz Herba
Nov 15 '17 at 7:22





Great to have documentation of module but how i am suppose to guess what is wrong with YOUR code if you are not sharing it nor the error logs?

– Bartosz Herba
Nov 15 '17 at 7:22










1 Answer
1






active

oldest

votes


















2














=> Go to your theme Folder and create file called addtocart.phtml and
past below code.



Quantity Increment and Decrement Button working fine by using below code



E.g :




app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/addtocart.phtml




<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block MagentoCatalogBlockProductView */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
<?php /*Add Plus Button */ ?>
<input type='button' value='+' class='qtyplus' field='qty' />
<div class="control">
<input type="number"
name="qty"
id="qty"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty"
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
<?php /*Add Minus Button */ ?>
<input type='button' value='-' class='qtyminus' field='qty' />
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
</button>
<?php echo $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"Magento_Catalog/product/view/validation":
"radioCheckboxClosest": ".nested"



</script>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"catalogAddToCart":
"bindSubmit": false



</script>
<?php endif; ?>
<?php /*JS FOR +-*/ ?>
<script type="text/javascript">
//&lt;![CDATA[
require(['jquery'], function ($)
setTimeout(function ()
// This button will increment the value
jQuery('.qtyplus').click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If is not undefined
if (!isNaN(currentVal))
// Increment
jQuery('input[name=' + fieldName + ']').val(currentVal + 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
// This button will decrement the value till 0
jQuery(".qtyminus").click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0)
// Decrement one
jQuery('input[name=' + fieldName + ']').val(currentVal - 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
, 100);
);
//]]&gt;
</script>





share|improve this answer

























  • After apply above code its not working in my case.only shows default box not increnment/decrement section.

    – Anikesh Shahi
    Nov 27 '17 at 6:57











  • any error in console ? Can you please share your code

    – Navin Bhudiya
    Nov 29 '17 at 4:47










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%2f201574%2fquantity-increment-and-decrement-button-not-work-in-magento-2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














=> Go to your theme Folder and create file called addtocart.phtml and
past below code.



Quantity Increment and Decrement Button working fine by using below code



E.g :




app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/addtocart.phtml




<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block MagentoCatalogBlockProductView */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
<?php /*Add Plus Button */ ?>
<input type='button' value='+' class='qtyplus' field='qty' />
<div class="control">
<input type="number"
name="qty"
id="qty"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty"
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
<?php /*Add Minus Button */ ?>
<input type='button' value='-' class='qtyminus' field='qty' />
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
</button>
<?php echo $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"Magento_Catalog/product/view/validation":
"radioCheckboxClosest": ".nested"



</script>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"catalogAddToCart":
"bindSubmit": false



</script>
<?php endif; ?>
<?php /*JS FOR +-*/ ?>
<script type="text/javascript">
//&lt;![CDATA[
require(['jquery'], function ($)
setTimeout(function ()
// This button will increment the value
jQuery('.qtyplus').click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If is not undefined
if (!isNaN(currentVal))
// Increment
jQuery('input[name=' + fieldName + ']').val(currentVal + 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
// This button will decrement the value till 0
jQuery(".qtyminus").click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0)
// Decrement one
jQuery('input[name=' + fieldName + ']').val(currentVal - 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
, 100);
);
//]]&gt;
</script>





share|improve this answer

























  • After apply above code its not working in my case.only shows default box not increnment/decrement section.

    – Anikesh Shahi
    Nov 27 '17 at 6:57











  • any error in console ? Can you please share your code

    – Navin Bhudiya
    Nov 29 '17 at 4:47















2














=> Go to your theme Folder and create file called addtocart.phtml and
past below code.



Quantity Increment and Decrement Button working fine by using below code



E.g :




app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/addtocart.phtml




<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block MagentoCatalogBlockProductView */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
<?php /*Add Plus Button */ ?>
<input type='button' value='+' class='qtyplus' field='qty' />
<div class="control">
<input type="number"
name="qty"
id="qty"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty"
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
<?php /*Add Minus Button */ ?>
<input type='button' value='-' class='qtyminus' field='qty' />
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
</button>
<?php echo $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"Magento_Catalog/product/view/validation":
"radioCheckboxClosest": ".nested"



</script>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"catalogAddToCart":
"bindSubmit": false



</script>
<?php endif; ?>
<?php /*JS FOR +-*/ ?>
<script type="text/javascript">
//&lt;![CDATA[
require(['jquery'], function ($)
setTimeout(function ()
// This button will increment the value
jQuery('.qtyplus').click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If is not undefined
if (!isNaN(currentVal))
// Increment
jQuery('input[name=' + fieldName + ']').val(currentVal + 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
// This button will decrement the value till 0
jQuery(".qtyminus").click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0)
// Decrement one
jQuery('input[name=' + fieldName + ']').val(currentVal - 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
, 100);
);
//]]&gt;
</script>





share|improve this answer

























  • After apply above code its not working in my case.only shows default box not increnment/decrement section.

    – Anikesh Shahi
    Nov 27 '17 at 6:57











  • any error in console ? Can you please share your code

    – Navin Bhudiya
    Nov 29 '17 at 4:47













2












2








2







=> Go to your theme Folder and create file called addtocart.phtml and
past below code.



Quantity Increment and Decrement Button working fine by using below code



E.g :




app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/addtocart.phtml




<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block MagentoCatalogBlockProductView */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
<?php /*Add Plus Button */ ?>
<input type='button' value='+' class='qtyplus' field='qty' />
<div class="control">
<input type="number"
name="qty"
id="qty"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty"
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
<?php /*Add Minus Button */ ?>
<input type='button' value='-' class='qtyminus' field='qty' />
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
</button>
<?php echo $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"Magento_Catalog/product/view/validation":
"radioCheckboxClosest": ".nested"



</script>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"catalogAddToCart":
"bindSubmit": false



</script>
<?php endif; ?>
<?php /*JS FOR +-*/ ?>
<script type="text/javascript">
//&lt;![CDATA[
require(['jquery'], function ($)
setTimeout(function ()
// This button will increment the value
jQuery('.qtyplus').click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If is not undefined
if (!isNaN(currentVal))
// Increment
jQuery('input[name=' + fieldName + ']').val(currentVal + 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
// This button will decrement the value till 0
jQuery(".qtyminus").click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0)
// Decrement one
jQuery('input[name=' + fieldName + ']').val(currentVal - 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
, 100);
);
//]]&gt;
</script>





share|improve this answer















=> Go to your theme Folder and create file called addtocart.phtml and
past below code.



Quantity Increment and Decrement Button working fine by using below code



E.g :




app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/addtocart.phtml




<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block MagentoCatalogBlockProductView */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<div class="box-tocart">
<div class="fieldset">
<?php if ($block->shouldRenderQuantity()): ?>
<div class="field qty">
<label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
<?php /*Add Plus Button */ ?>
<input type='button' value='+' class='qtyplus' field='qty' />
<div class="control">
<input type="number"
name="qty"
id="qty"
maxlength="12"
value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty"
data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
/>
<?php /*Add Minus Button */ ?>
<input type='button' value='-' class='qtyminus' field='qty' />
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
class="action primary tocart"
id="product-addtocart-button">
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
</button>
<?php echo $block->getChildHtml('', true) ?>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"Magento_Catalog/product/view/validation":
"radioCheckboxClosest": ".nested"



</script>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">

"#product_addtocart_form":
"catalogAddToCart":
"bindSubmit": false



</script>
<?php endif; ?>
<?php /*JS FOR +-*/ ?>
<script type="text/javascript">
//&lt;![CDATA[
require(['jquery'], function ($)
setTimeout(function ()
// This button will increment the value
jQuery('.qtyplus').click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If is not undefined
if (!isNaN(currentVal))
// Increment
jQuery('input[name=' + fieldName + ']').val(currentVal + 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
// This button will decrement the value till 0
jQuery(".qtyminus").click(function (e)
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = jQuery(this).attr('field');
// Get its current value
var currentVal = parseInt(jQuery('input[name=' + fieldName + ']').val());
// If it isn't undefined or its greater than 0
if (!isNaN(currentVal) && currentVal > 0)
// Decrement one
jQuery('input[name=' + fieldName + ']').val(currentVal - 1);
else
// Otherwise put a 0 there
jQuery('input[name=' + fieldName + ']').val(0);

);
, 100);
);
//]]&gt;
</script>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 17 '17 at 6:10









Rohan Hapani

6,56831864




6,56831864










answered Nov 17 '17 at 6:01









Navin BhudiyaNavin Bhudiya

7491024




7491024












  • After apply above code its not working in my case.only shows default box not increnment/decrement section.

    – Anikesh Shahi
    Nov 27 '17 at 6:57











  • any error in console ? Can you please share your code

    – Navin Bhudiya
    Nov 29 '17 at 4:47

















  • After apply above code its not working in my case.only shows default box not increnment/decrement section.

    – Anikesh Shahi
    Nov 27 '17 at 6:57











  • any error in console ? Can you please share your code

    – Navin Bhudiya
    Nov 29 '17 at 4:47
















After apply above code its not working in my case.only shows default box not increnment/decrement section.

– Anikesh Shahi
Nov 27 '17 at 6:57





After apply above code its not working in my case.only shows default box not increnment/decrement section.

– Anikesh Shahi
Nov 27 '17 at 6:57













any error in console ? Can you please share your code

– Navin Bhudiya
Nov 29 '17 at 4:47





any error in console ? Can you please share your code

– Navin Bhudiya
Nov 29 '17 at 4:47

















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%2f201574%2fquantity-increment-and-decrement-button-not-work-in-magento-2%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

Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її