Add to cart was not working on local server and it was fixed by changing the base_url in database from "http://localhost/magento2" to "".

Now after all design changes when this installation was moved to live server, we made the respective changes in DB, env.php and cleared cache.

Every link and all functionalities are working fine except 'Add to cart' functionality has stopped working.

Following are the issues with 'Add to cart':

  1. On category page (product listing page): when 'Add to cart' button is clicked, it directly takes to 'cart' page without adding product to cart.

  2. On Product detail page: When clicked on 'Add to cart' button, its text changes to 'Adding' and it stays the same and product is never added to cart.

There are no errors in console for both of the above scenarios.

Following I have tried:

Deleted following directories:

  • pub\static
  • var\cache
  • var\page_cache
  • var\view_preprocessed
  • var\composer_home

Ran these commands using ssh:

  • php bin/magento setup:static-content:deploy
  • php bin/magento indexer:reindex

And following commands to give magento's default permissions to directories:

  • sudo chmod -R a+wX pub
  • sudo chmod -R a+wX var
  • sudo chmod -R a+wX app
  • sudo chmod -R a+wX app/etc
  • sudo chmod -R a+wX generated

Updated cookie_lifetime to 86400 in admin.

Cleared cache from admin.

But still issue persists.

Please help in resolving this.

  • Would you see the Magento logs? – Rishabh Rk Rai Jan 17 '18 at 6:38
  • Please, check corresponding request in the network tab in console of your browser. Perhaps you can find responce with a text of the error returned by your web-server. – Siarhey Uchukhlebau Jan 17 '18 at 8:47
  • @SiarheyUchukhlebau: I have checked it there are no errors in network or console when clicked on add to cart. – Wasiq Shahrukh Jan 17 '18 at 9:24
  • Can you see the request? What is returned in the response? – Siarhey Uchukhlebau Jan 17 '18 at 11:22
  • In my instalation occur the same problem when I move to php71u. I rebuild my docker images with php70u and now I can add product in my cart again. – Felipe Castilla Mar 30 '18 at 16:25

Are you using apache? Make sure .htaccess file is been read or else try adding index.php to url.

Also make sure Php rewrite module is enabled.

  • Tried with index.php still not working and rewrites module is already enabled. – Wasiq Shahrukh Jan 17 '18 at 13:18
  • 1
    hey this is worked for me. I have given permissions again then it worked normally. Thank you for view on this – Jdprasad V Mar 13 '20 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.