🔥 Just Launched! Werra Premium Template for HyväSee it in Action

Solved: Magento 2 Add to Cart Button Not Working

By Sanjay JethvaUpdated on Jul 17, 2025 3 min read

Its been almost two years now since Magento 2 has been released, and it’s getting better with each day due to the contributions from the developers all over the world. However, there are certain issues you may face while working with Magento 2. One of them is “Magento 2 Add to Cart button not working“.

There are many reasons for add to cart not working or stopped working. Some of them are infinite redirection loop, 3rd party extension conflicts, form_key mismatch etc.

Magento 2 Add to Cart button not working on Home page

Most of the time, the issue arises due to change in custom theme, adding custom CSS, adding products to cart from home page and refreshing the page doesn’t add the product to cart.

Such a situation arises when there’s something wrong in the cache.

Follow the below steps to solve the issue:

1. Login to Magento 2 backend.

2. Go to System > Cache Management and select all of the caching options built in your Magento 2.

3. In the drop-down, select Enable and then click on Submit.

enabling cache types

And you’re done!

Magento 2 Add to Cart button not working on the Categories and Product Page

When a user adds a product to cart from categories or product page, he/she is redirected to the checkout page with an empty cart. This happens because of the domain change as Magento 2 stores root URL in the third path without affecting the first version.

To resolve the issue, you need to run 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';

Moreover, delete the cache using the following command:

rm -rf var/cache/*

Now that you have the solution, don’t let such small issues stop your live Magento 2 store work well. ?

Happy Coding!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.