Unable to remove items from WooCommerce cart on NGINX [Fix]

Updated on November 1, 2018

I recently migrated my client website from Apache web server to NGINX and while testing the site, I noticed that the items in cart page were not removing. When a remove button next to each item in the WooCommerce cart was clicked, the Ajax just re-loads the page and no item was removed from the cart. If you are unable to remove items from WooCommerce cart, then here’s a fix.

Unable to remove items from WooCommerce cart on NGINX [Solution]

It’s because of the NGINX configuration. Look out for the below section in  NGINX configuration file.

location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}

Replace it with the below section.

location / {
try_files $uri $uri/ /index.php?$args;
}

Save the configuration file and restart the NGINX server

# systemctl restart nginx

That’s it. Now I was able to remove items from the cart in WooCommerce.

Still not able to remove the items from the cart? Then you might be using cache plugin and the below solution might help.

Configure W3 Total Cache properly

DONOTCACHEPAGE

According to the WooCommerce developers, WooCommerce version starting from 1.4.2 and above sets the DONOTCACHEPAGE constant, which means caching plugins will not cache WooCommerce dynamic pages anymore.

According to various forums, the issue is mostly because of the improper handling of the website cache. So if you are using WP Total Cache or WP Super Cache or any other cache plugin, then make sure you disable it and test if you are able to remove the items from the cart. If the issue is fixed after disabling the cache plugin, then you need to re-activate the plugin and see what cache setting is causing the issue. For example, if you are using W3 Total Cache, then you need to disable Set expires header under Browser cache > General. Also, you might try adding /cart/* and /checkout/* under the page exceptions in Page Cache > Advanced > Never cache the following pages

Was this article helpful?

Related Articles

Comments Leave a Comment

  1. Wow, been wrestling with this for more than a day – thanks SO much!!! Top

  2. Thanks. This really worked, after a lot of ‘solutions’ didn’t!

Leave a Comment