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.

  • Have you customize anything or extended any js ? Commented Apr 22, 2016 at 11:39
  • have you got this answer @user15917
    – Devidas
    Commented Oct 27, 2018 at 7:23

4 Answers 4


from addtocart.phtml

<input type="number" 
    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.

  • 1
    I have added this code: <script type="text/x-magento-init"> { "#product_addtocart_form": { "Magento_Catalog/product/view/validation": { "radioCheckboxClosest": ".nested" }, "catalogAddToCart": { "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>", "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>", "addToCartButtonTextAdded": "<?php echo __('Added'); ?>" } } } </script> in vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml
    – user15917
    Commented Apr 26, 2016 at 11:50

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.

Your Answer

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