1

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 "http://127.0.0.1/magento2".

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.

5
  • Would you see the Magento logs? Jan 17, 2018 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. Jan 17, 2018 at 8:47
  • @SiarheyUchukhlebau: I have checked it there are no errors in network or console when clicked on add to cart. Jan 17, 2018 at 9:24
  • Can you see the request? What is returned in the response? Jan 17, 2018 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. Mar 30, 2018 at 16:25

1 Answer 1

3

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.

2
  • Tried with index.php still not working and rewrites module is already enabled. Jan 17, 2018 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, 2020 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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