How to fix not working Add To Cart Button in Magento 2?

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

  1. The customer will finalize the product very first.
  2. All the details regarding size and color will be selected
  3. 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 he likes the product, but 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 in 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 from 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 for getting not losing 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 arise any js error.

Check the screenshot as under:

Magento add to cart errorFor example, if you have 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)

Magneto add to cart not showing 2The other option you have is to test by changing the theme. You will need to change the theme to default Magento 2 theme which is “Luma” if the button starts working after changing to this theme, then you are having the 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 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 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 product, then you will need to run the SQL query.
Magento 2 stores 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=’web/cookie/cookie_lifetime’;
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:

Go to vendor/magento/module-checkout/Controller/Cart/Add.php execute() method.
Comment out the first if condition which checks the session and posted form key.
//if (!$this->_formKeyValidator->validate($this->getRequest()))>
{//return $this->resultRedirectFactory->create()->setPath(‘*/*/’);

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.

Related Post :

Leave A Comment

Your email address will not be published. Required fields are marked *