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?

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

World War I as a war of liberals against authoritarians?

Recruiter wants very extensive technical details about all of my previous work

Existence of a celestial body big enough for early civilization to be thought of as a second moon

Violin - Can double stops be played when the strings are not next to each other?

Synchronized implementation of a bank account in Java

What is the English word for a graduation award?

Optimising a list searching algorithm

What can I do if I am asked to learn different programming languages very frequently?

Do US professors/group leaders only get a salary, but no group budget?

Help prove this basic trig identity please!

Bash - pair each line of file

Can a medieval gyroplane be built?

Practical application of matrices and determinants

What is the term when voters “dishonestly” choose something that they do not want to choose?

If "dar" means "to give", what does "daros" mean?

Can other pieces capture a threatening piece and prevent a checkmate?

What is the significance behind "40 days" that often appears in the Bible?

A Ri-diddley-iley Riddle

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

Why are there no stars visible in cislunar space?

Why is indicated airspeed rather than ground speed used during the takeoff roll?

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?



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 4 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

Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

Aasi (pallopeli) Navigointivalikko