How to fix not working Add To Cart Button in Magento 2?
Customers are the king of the business. Kings should be treated with the utmost care. If you are in the eCommerce industry selling your products at effective rates in this competitive market, you are going to fetch the customers. Online shopping trend has been increased nowadays. People have become smart with technology and even smarter with shopping. Online shopping provides them with more options to select from as well as the shopping feels more comfortable on an online platform.
Online shopping is done by following a few steps
- The customer will finalize the product very first.
- All the details regarding size and color will be selected
- The product will be added to the cart by clicking the Add to cart button
Even after the customer selects all the details as well as likes the product, if your Magento add to cart button is not working and is taking more time and if there is a problem with the order process, the customers are not going to wait. They will simply bounce back from your website and start searching for some other website. The bounce rate will increase because of the problem with the Add to cart button on your site. Shopping cart abandonment will cause you to lose your hard-earned customers.
You will have to get the issue solved by reputed Magento Development Company, they have the ability to turn around with solutions at a greater speed. Hiring certified developers is an added advantage and if you know technical, you can solve this as I have listed some of the issues faced with add to cart button and also the measures to solve.
If by clicking on add to cart button, nothing happens, the problem needed to be solved quickly forgetting not to lose your sales. There are various factors for Magento’s add to cart not working and they are your Magento 2.3 session has expired or might be possible that Magento 2 add to cart not working on localhost.
The Button “add to Cart” triggers the JS method to submit the add to cart Form. So if the form is not working then, you will be having some JS issues on that page that issue prevents any JS execution, as well as there, are also chances that the button is not working due to some jQuery incompatibility or other. You will have to check the console box if there arises any js error.
Check the screenshot as under:
For example, if you have a chat function on the page and the js on the chat function is overriding the “add to cart”-button then the best way to check the same is by trying to unmerge the js setting from admin, so it will give you the js error.
What you will have to do is go to the admin and then you will have to untick “Merge JavaScript Files” (system > configuration > developer)
The other option you have is to test by changing the theme. You will need to change the theme to the default Magento 2 theme which is “Luma” if the button starts working after changing to this theme, then you are having an issue with your custom theme add to cart form, also you can check if there is any lightbox or zoom extension added up there, then you will need to disable these extensions and then check once again, you will find the issue.
Magento 2 Add to Cart not working from the homepage
When anybody does add to a cart product from the home page using the button and then nothing is seen in the cart, just a refreshed page, and then you receive a success message that the product has been in the cart.
The problem resides in cache, you will just have to enable all caching options built in your Magento 2.
Magento 2 Add to cart not working from categories and products page
When you are adding products from the product page and you are then redirected to the checkout page with Magento 2 shopping cart empty even after adding a product, then you will need to run the SQL query.
Magento 2 stores the root URL in the third path, e.g.: design/head/includes.
This issue occurs after domain change or changing the hosting.
You will need to run an 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/*
Add to cart not working after Migration
If your Magento 2 website’s add to cart is not working after you have migrated the same to the new server, then there might be a problem with the timezone. You can solve the same by increasing the values for two config items in core_config_data:
UPDATE core_config_data SET value=86400 WHERE path=’admin/security/session_cookie_lifetime’;
Magento add to cart not working due to key mismatch
If you face the problem, due to form_key mismatch, which gets posted during add to cart action and the stored Session you see the value-form key is mismatched.
You will have to:
Comment out the first if condition which checks the session and posted form key.
//if (!$this->_formKeyValidator->validate($this->getRequest()))>
Magento 2 Add to Cart button stuck at Adding
If you’ve been operating Magento locally and using the default http://localhost/ as the base URL, it is quite possible that your base URL is the issue. To resolve this issue, change your base URL to http://127.0.0.1/ to maximize compatibility. To do this, go to your database and locate the core config data table.
Here, you’ll concentrate on these two rows:
- web/unsecure/base_url
- web/secure/base_url
Change only localhost to 127.0.0.1 and keep everything else the same. If your base URL is http://localhost/magento24, for example, you must change it to http://127.0.0.1/magento24.
Make sure to clear your cache after modifying your base URL.
Thus, one needs to solve the issue. Hire certified developers from the Magento web development company so that you don’t lose your genuine customers and your business doesn’t face the loss.