Magento add to cart button not working is one of the popular errors in Magento 2 website. There are many reasons for add to cart not working or stopped working. Some of them are infinite redirection loop, 3rd party , module conflicts, form_key mismatch, etc. In this blog today, we would love to provide you some solution to fix this problems.
What is Magento add to cart button and its benefits?
The add to cart button is one of the most crucial elements of every e-commerce store. This button displays on different pages of your website like the home page, product page, and category list page. With this button, shoppers can add their desired products to the shopping cart, then move to the checkout page or continue their shopping journey. The add to cart button displays on various pages helps them to find faster. Therefore, what if the Add to Cart button is not functioning? Once the add to cart button is not working the customers will not wait and will switch to another one store. This will have a negative impact on the revenue of the business and affect the customer experience. You will lose your customers’ trust in your brand. Therefore, go next part to know the reasons and solutions for Magento 2 “Add To Cart” Button Not Working.
Why Magento add to cart button not working?

It is terrible for web owners if the add to cart suddenly stops working on your Magento 2 store. One of the bad effects that can cause your business is losing sales. Loyal customer
may drop their cart and leave your store if they find out the add to cart button stop working. The more severe impact is that users will evaluate your store with the not good technical background, and they are suspicious about the security of the website. As a result, they will not go back to purchase in the future.
The shop owners do not want this errors to happen so that they often find the reason for this issues and try to solve it in the shortest time. There are some reasons for add to cart not working. It may be due to the conflict with themes or third-party modules. Besides, if the admin customize themes by modifying coding or add custom CSS, the add to cart button issue may occur. Furthermore, the errors might happen due to a domain change as Magento 2 stores root URL in the third path.
How to fix this error effectively in Magento 2
1. Add to Cart button does not work on the Home page
The problem:
- You have configured a custom theme for your Magento 2 website. However, you haven’t made any significant adjustment, you 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 get a Magento message that the product has been added to the cart.
- Then you move to the product page and add another product to the cart. The cart is updated right after the button is pressed and you see two items there: the one you added right now and the product you placed to cart from the homepage.
The solution: The method is so simple, there is every likelihood the problem appear in the cache. So, you need to enable all caching options built-in in your Magento 2. In the most of situations, the problem happen due to a change in the custom theme, adding custom CSS, adding items to the cart from the home page, and refreshing the page doesn’t add the item to the cart. Such a situation occur when there’s something wrong in the cache. Follow some steps to fix the issue:
- Login to Magento 2 backend.
- Move to System > Cache Management and choose all of the caching options built-in in your Magento 2 website.
- In the drop-down, choose Enable and then click on Submit.
2. Add to Cart does not work on product pages: “I can’t add products to the cart”
The problem: When adding items from the catalog or product page, your customers are redirected to the checkout page with an empty cart.
The solution: The thing is that despite the first version, Magento 2 website the root URL in the third path, e.g.: design/head/includes. Normally, the problem appear after domain change.
- You have 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, you need to delete the cache by following the below command:
rm -rf var/cache/*
3. Magento 2 Add to Cart button stuck at Adding
If you’re running Magento on a local environment and using the default http://localhost/ as the base URL, it’s possible that your base URL is the problem. To solve this problem, you’ll need to change your base URL to http://127.0.0.1/ as this way to ensure better compatibility. To perform this, you’ll need to access your database and find the core_config_data
table.
Here you’ll focus on these two rows:
web/unsecure/base_url
web/secure/base_url
Now you change only localhost
to 127.0.0.1
and keep everything else the same. For instance, if your base URL is http://localhost/magento24
, you’ll have to change it to http://127.0.0.1/magento24
.
After changing your base URL, remember to flush your cache using
php bin/magento cache:flush
Conclusion

That’s all about Exception printing is disabled by default for security reasons. After all, we hope that you found this tutorial helpful. Besides, if you are looking for effective solutions to increase the cart conversion rate and speed up the work of the cart page with AJAX technology, then you can direct Magesolution for our powerful Magento Website Development Services. Contact us for free consultation.