More fixes

WooCommerce cart empty after adding a product

The shop says "added to your cart", but the cart page shows Your cart is currently empty, the cart icon stays at 0, or the cart empties when the customer reaches checkout. Customers who see this leave. It is almost always one of two things: a cached copy of the cart page, or the shop losing track of who the customer is. Two checks tell you which.

Customer sees

What the checks found


  

Check 1: is the cart page cached?

Open the shop in a private window, add a product, then open the cart page with ?nocache=1 added to its address (for example /cart/?nocache=1). If the product shows there but not on the plain /cart/ address, a cache is serving an old, empty copy of the page. Look at every cache layer you have: a caching plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache), your host's server cache, and Cloudflare. Each must leave the cart, checkout and my account pages uncached, and must not cache pages for visitors who carry the woocommerce_items_in_cart or wp_woocommerce_session_ cookies.

Check 2: does the session cookie survive?

Still in the private window, press F12, open Application (Chrome) or Storage (Firefox) and then Cookies. After adding a product you should see a cookie starting with wp_woocommerce_session_. If it never appears, or appears and then disappears on the next page, the shop cannot remember the cart. Common reasons: the site mixes www and non-www or http and https addresses, so the cookie is set on one and read on the other; a cookie consent plugin blocks WooCommerce cookies until the visitor clicks accept; or Cloudflare or a security plugin strips cookies.

What each answer means

What you seeCauseFix
Product appears with ?nocache=1, not withoutCart page cached by a plugin, the host or CloudflareExclude cart, checkout and my account from every cache layer, and skip cache for visitors with WooCommerce cookies; then purge all caches
Cart icon stays at 0 but the cart page is rightThe mini cart in the header is cached or its refresh script is delayed by a speed pluginExclude wc-cart-fragments from JavaScript delay and combine options
No session cookie, or it vanisheswww/non-www or http/https mismatch between the WordPress Address and Site AddressMake both addresses in Settings > General identical and redirect every other form to that one
Cart works only after accepting cookiesA consent plugin blocks WooCommerce's necessary cookiesMark the WooCommerce session and cart cookies as strictly necessary in the consent plugin
Cart empties on the way to checkoutCart and checkout pages on different addresses, or a checkout page that is not the one set in WooCommerce settingsCheck WooCommerce > Settings > Advanced: the cart and checkout pages are the real ones, on the same domain
Cart empties after some minutes or hoursSessions are cleared early, often by a database cleanup plugin emptying the sessions tableStop the cleanup plugin from touching woocommerce_sessions; WooCommerce clears expired sessions itself
Products added, nothing happens at allA JavaScript error on the product page stops the add to cart requestRead the Console on the product page; see the add to cart guide linked below

Check it worked

Purge every cache, then in a fresh private window add two different products, open the cart, change a quantity, and go through to checkout. The cart count, the cart page and the checkout order summary should all agree. Repeat once on a phone over mobile data, since some caches only serve phones.

What not to do

If you would rather someone else finds why the cart empties and fixes it, that is what the box below is for. Related: add to cart button not working, checkout not working, changes not showing (cache).