Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product is added to cart twice the quantity when customer clicks Add To Cart button second time #16063

Closed
bnymn opened this issue Jun 12, 2018 · 6 comments
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@bnymn
Copy link
Contributor

bnymn commented Jun 12, 2018

Products are added to the cart twice the quantity, when you click on Add To Cart button more than one.

Preconditions

  1. Ubuntu 18.04
  2. PHP 7.1.18
  3. MySQL 5.7.22
  4. Magento 2.2.4
  5. Google Chrome 67.0.3396.79 or Firefox 60.0.1

Steps to reproduce

  1. Create a simple product in the Magento Admin.
  2. Go to product detail page in Store Front.
  3. Change the quantity to 5.
  4. Click on Add To Cart.
  5. Verify the quantity by looking at the Mini Cart at the upper-right corner.
  6. Click on Add To Cart again.
  7. Verify the quantity is now 15, instead of 10.

Expected result

  1. I expect to add to cart the given quantity whenever I click Add To Cart button.

Actual result

  1. After the first time, it always add the twice the quantity to the cart. When I inspect the network, I see there is two calls.
    screenshot from 2018-06-12 10-18-26
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 12, 2018
@hostep
Copy link
Contributor

hostep commented Jun 12, 2018

Hi @bnymn, thanks for the well written issue!

But I'm going to close it, as it has already been reported before in #15052 & #15580

Quick summary: it's a new bug introduced in one of those new modules from Amazon which get installed by default now in Magento 2.2.4. Quick fix is if you don't need those modules to simply disable them, which should fix your issue. If you don't want to disable those modules, it is mentioned over here that a fix is pending for Magento 2.2.5: amzn/amazon-payments-magento-2-plugin#227

@hostep hostep closed this as completed Jun 12, 2018
@vasudevsundar
Copy link

Hi,
I am too facing add to cart issue, like adding product twice for second time onwards.

Once disabled Amazon module, works fine, is there any other solutions without disabling module for Magento 2.2.4 .

@swishhh
Copy link

swishhh commented Jul 20, 2018

@vasudevsundar Hey, how did you disable amazon module? I wanna do it correctly, cause i don't use it anywhere

@hostep
Copy link
Contributor

hostep commented Jul 20, 2018

@swishhh, you have two options:

  1. In composer, define that you don't want to download and install those modules, by adding these lines to the composer.json file:
    "replace": {
        "amzn/amazon-pay-and-login-magento-2-module": "*"
    }

Then run composer update, followed by a bin/magento setup:upgrade.

After this, there won't be any trace of the Amazon modules code in your project, there might still be some leftovers in the database though, but that's less important and shouldn't cause problems.

  1. Disable the modules in Magento, by running this command:
    bin/magento module:disable Amazon_Core Amazon_Login Amazon_Payment

After this, the code of the Amazon modules is still in your project, but it is just not active.

You can choose whatever you're most comfortable with :)

@swishhh
Copy link

swishhh commented Aug 8, 2018

@hostep thanks a lot :)

@Jeeva-Rathinam
Copy link

Jeeva-Rathinam commented Aug 20, 2018

Any one help me how can i add add-to-cart button on CMS. I need Name, Thumbnail Image, Price, Add-to-cart Button On CMS PAGE, here add to cart not woking,

code :

file path: app/desgin/frontend/base/default/template/myphp/myphpcode.phtml

Place the below code

<?php $_productCollection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToSelect('*');
?>
<table>
 <tr>
  <th class="prosku">Sku</th>
  <th class="proname">Name</th>
  <th class="proprice">Price</th>
  <th class="proimg">Thumbnail</th>
  <th class="pro-button">Add to Cart Button</th>
 </tr>
<?php 
    if(count($_productCollection)) {
        foreach($_productCollection as $product) {
?>
 <tr>
  <td class="prodsku"><?php echo $product->getSku(); ?></td>
  <td class="prodname"><?php echo $product->getName();?></td>
  <td class="prodprice"><?php echo $product->getPrice();?></td>
  <td class="prodimg"><img src="<?php echo $product->getImageUrl();?>" width="100px" height="100px"/></td>
  <td class="prod-add_to_Cart-button"><?php if($product->isSaleable()): ?>
   <p><button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
   <?php else: ?>
   <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
   <?php endif; ?></td>
 </tr>
<?php
}
    }
?>
 </table>
<style type="text/css">
.prodsku, .prodname, .prodprice,  .prodimg, .prod-add_to_Cart-button{
	padding:10px;
}
.prosku, .proname, .proprice,  .proimg, .pro-button{
	padding:10px;
}
</style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

6 participants