Magento 2 'Add to Cart' is not working

The issue is common among merchants who have implemented custom solutions or just migrated to Magento 2 version. There are many variants of the problem outcome, though let’s consider the commonest.

To increase the cart conversion rate, speed up the work of the cart page with AJAX technology. Your customers will see products in the AJAX cart popup where they can edit or refill the shopping baskets without page reloading.

Magento 2 Add to Cart is not working from homepage

The issue: 

  • You have configured a custom theme for your Magento 2 shop. However, you haven’t made any significant changes, just removed some links and added custom CSS. 
  • When adding a product right from the home page you click the Magento ‘Add to Cart’ button and see nothing in the cart, just a refreshed page. Though you receive Magento message that the product has been added to the cart. 
  • Then you go to the product page and add another item to the cart. The cart is updated right after the button is pressed and you see two products there: the one you added right now and the item you placed to cart from the homepage.

The solution:

The solution is simple, there is every likelihood the problem resides in cache. So, enable all caching options built-in your Magento 2.

Magento 2 Add to Cart is not working on product pages: I can’t add products to the cart

The issue:

When adding products from the catalog or product page you are redirected to the checkout page with an empty cart.

The solution:

The thing is that despite the first version, Magento 2 stores root URL in the third path, e.g.: design/head/includes. Usually, the issue occurs after domain change.

  • You need to run an additional SQL query:
UPDATE core_config_data
SET value = REPLACE(value, '<old root URL or domain>', '<new root URL or domain>')
WHERE path = 'design/head/includes';

 

  • Then delete the cache using the command:
rm -rf var/cache/*
How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2024 Amasty. All Rights Reserved.