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.

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 ‘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: I can’t add products to 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 create 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/*
Rate the answer?