Add quantity 2 when adding to cart from product view page.
For only one product because it calls a 2-time post request for one product.
After clearing cache and checking and some time that works, but again that problem comes in other product.
Add quantity 2 when adding to cart from product view page.
For only one product because it calls a 2-time post request for one product.
After clearing cache and checking and some time that works, but again that problem comes in other product.
from addtocart.phtml
<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())) ?>" />
change value to "2"
Hello it happen with me.
Solution for that:addtocart intilize two times on page so find out and remove it
The \Magento\Checkout\Controller\Cart\Add::execute()
method has support for the qty
request param. Try adding a new hidden input named qty
and a value of 2
in the add-to-cart form template file.
Maybe there's a more elegant way of doing this, but I don't know about it yet.
Have you considered using the built in functionality within magento for Minimum Qty Allowed in the Shopping Cart just make sure you set Enable Qty Increments and set the Qty Increments value this should give the customer a notification prior to adding to the shopping cart thus preventing the need for adding to cart multiple times.