A shopper clicks “Add to cart”, sees the confirmation, clicks through to the basket and reads “Your cart is currently empty.” Or the cart looks fine until they reach checkout, which then claims there is nothing to pay for. Or the little cart icon in the header says three items while the cart page says none.
Most store owners only hear about this when a customer complains, and many customers never complain. They just leave. The good news is that an emptying cart almost always comes down to one of a few causes, and the top two are about caching and cookies rather than anything broken inside WooCommerce.
How WooCommerce remembers a cart
A visitor who is not logged in has no account, so WooCommerce needs another way to know which cart belongs to whom. When someone adds a product, WooCommerce sets a session cookie in their browser (its name begins with wp_woocommerce_session_) along with small helper cookies such as woocommerce_items_in_cart and woocommerce_cart_hash. The cart contents themselves are stored in the database, in a sessions table, against the identifier in that cookie.
Every time the shopper loads a page, their browser sends the cookie back, and WooCommerce looks up their cart. Break any link in that chain, and the cart appears empty:
- The cookie is never set, or is set for a different address.
- The cookie is sent, but the page served was a cached copy built for someone else.
- The session in the database is missing or cannot be written.
For the wider set of WordPress and WooCommerce errors and where each one is explained, start with our guide to fixing WordPress errors.
Cause 1: the cart or checkout page is being cached
This is the most frequent cause by some distance. Page caching saves a ready-made copy of a page and hands it to every visitor. That is excellent for your home page and product pages. It is a disaster for the cart, checkout and My Account pages, because those must be built fresh for each shopper.
If a cached cart page was saved while it was empty, every visitor sees an empty cart. If it was saved while someone else’s items were in it, visitors may see that person’s cart, which is worse.
Caching can happen in several places at once:
- A caching plugin such as WP Rocket, LiteSpeed Cache, W3 Total Cache or WP Super Cache. Most of them detect WooCommerce and exclude its pages automatically, but the exclusions can be lost if the cart page was recreated with a new address or the plugin was misconfigured.
- Server-level caching provided by your host, such as Varnish, Nginx caching or LiteSpeed’s server cache. These are configured in the hosting panel, not in WordPress.
- A CDN such as Cloudflare. A “cache everything” rule applied to the whole site will cache the cart unless the store pages are explicitly bypassed.
How to test it
- Open a private window, add a product and go to the cart. Then do the same in a second private window or another browser. If both show the same thing regardless of what you added, the page is cached.
- Check the page’s response headers in your browser’s developer tools (F12, then Network, click the page request). Headers such as
x-cache: HIT,cf-cache-status: HITor a LiteSpeed cache header on the cart page are a clear sign. - Go through each caching layer and make sure the cart, checkout and My Account pages are excluded, and that pages are not cached for visitors who have the WooCommerce cookies.
Cause 2: the site address changes as the shopper moves around
Cookies belong to an exact host name. A cookie set on www.example.com is not necessarily sent to example.com, and cookies marked secure are not sent over plain http. If your product pages load on one version of the address and the cart on another, the shopper’s browser arrives at the cart without its session cookie.
This often happens after an SSL change or a migration, when Settings > General has one address but links, menus or redirects use another. Check that:
- Both address fields in Settings > General use the same https address.
- Your server redirects every other version (http, www or non-www) to that one address.
- Menus, buttons and hard-coded links in the theme do not point to an old address.
Mixed http and https links after a move also cause other quiet problems; our article on mixed content after switching to https explains how to find them.
Cause 3: optimisation that removes the cart scripts
WooCommerce uses a small script often called cart fragments to refresh the mini-cart in the header without reloading the page. Some speed plugins and guides recommend switching it off, because it adds a request on every page. That can be a reasonable trade-off, but on some themes it leaves the header count stale, so the icon and the cart page disagree. Script delay and combine features can have the same effect on the add-to-cart buttons on archive pages.
If the mini-cart shows the wrong number but the cart page itself is correct, look here first. Turn the optimisation off, test, and if it fixes the count, either keep the script enabled or exclude it from that particular optimisation. Our speed optimisation service page explains how we balance this on stores that need to stay fast.
Cause 4: sessions not being saved
Less often, the cookie arrives and the page is fresh, but the cart data in the database is missing. Signs include carts that empty after a few minutes, or only on busy days.
- The database user may lack permission to write, or the database may be full on a small hosting plan.
- A persistent object cache (Redis or Memcached) that is misconfigured or clearing itself constantly can lose session data.
- A plugin or custom code may be clearing the cart on certain pages, for example a “buy now” feature that empties the cart before adding a single product.
- A PHP error when the session is written. The WooCommerce logs (WooCommerce > Status > Logs) and
wp-content/debug.logwill show it if debug logging is on.
WooCommerce > Status > Tools includes an option to clear customer sessions. Use it only if you understand that every shopper’s current cart will be emptied. It is a clean-up tool, not a fix.
Cause 5: the shopper’s own browser
Sometimes it really is one customer. Browsers set to block all cookies, privacy extensions, or in-app browsers inside social media apps can prevent the session cookie from sticking. If only one person reports it and you cannot reproduce it in any normal browser, ask what device and browser they are using, and suggest trying a standard browser instead.
A note on block-based cart and checkout pages
Newer stores often use the Cart and Checkout blocks instead of the older shortcodes. The blocks talk to WooCommerce through the REST API, so they are affected by anything that blocks or caches requests to /wp-json/. If your cart page is built with blocks and stays empty while the shortcode version works on a test page, look at your firewall, security plugin and CDN rules for those API requests. A cache that stores API responses can produce exactly the same “empty cart for everyone” effect as a cached page. The same applies to some theme mini-carts, which also fetch the cart in the background.
If you are not sure which version your store uses, edit the cart page: blocks show as a Cart block in the editor, while the older approach shows a single shortcode.
A careful testing order
An emptying cart is easy to make worse by changing several things at once. Take a backup, then work through it in this order, testing in a fresh private window after each step:
- Reproduce the problem as a logged-out visitor and note exactly where the cart empties.
- Purge every cache: plugin, server and CDN.
- Confirm cart, checkout and account pages are excluded at every layer.
- Check that the address stays the same from product page to checkout.
- Switch off script optimisation and retest.
- Check the logs for errors when products are added.
- Only then start deactivating plugins, preferably on a staging copy of the store so real carts are not affected.
Keeping the cart reliable
- After changing any caching, CDN or speed setting, add a product as a logged-out visitor and go all the way to the payment page.
- Keep a single canonical address and redirect everything else to it.
- Do not stack two page caching plugins, or a plugin cache on top of a host cache, unless you know exactly which one handles store pages.
- If you move the cart or checkout page, or rebuild it with blocks, check that your caching exclusions still match the new address.
When to ask for a second pair of eyes
If the cart empties only sometimes, only on mobile, or only for some customers, the cause is usually a combination of layers that is hard to see from the dashboard. Send us the steps that reproduce it and the address of a product to test with. We will look at each layer, take a backup before changing anything, and explain what was wrong. If customers are also reaching checkout and failing there, our page on WooCommerce checkout problems is the right place to start.
Next in this series: WooCommerce Tax or Shipping Wrong at Checkout? Fix It