Imagine a customer browsing your e-commerce store, carefully selecting items, and adding them to their shopping cart. They eagerly click the "Proceed to Checkout" button, only to be greeted by a frustrating, blank page or an aggressive message stating: "Your cart is currently empty." This phenomenon is widely known in the WordPress community as the WooCommerce "Ghost Cart" bug. It most frequently occurs right after a major WooCommerce core update or after installing a new optimization plugin. The root cause of this glitch is almost never WooCommerce itself; rather, it is a severe conflict with page caching or object caching mechanisms.

When a caching plugin (such as WP Rocket, LiteSpeed Cache, or W3 Total Cache) aggressively caches dynamic pages, it inadvertently stores a single, static version of the cart or checkout page. As a result, when a new user visits the site, the server serves them the cached, empty version of the page instead of generating a unique session for their specific browser. This breaks the PHP sessions and WooCommerce transients that are responsible for remembering what the user wanted to buy.

 

The Solution

To permanently resolve the Ghost Cart issue, you must instruct your server and caching plugins to completely bypass caching for all dynamic WooCommerce endpoints.

  1. Exclude Pages from Caching: Navigate to your caching plugin settings (e.g., WP Rocket -> Advanced Rules). Find the section labeled "Never Cache URLs" and add the following paths:

    Plaintext
     
    /cart/
    /checkout/
    /my-account/
    
  2. Purge All Cache: Clear your WordPress plugin cache, your server-level cache (like Varnish or Nginx FastCGI), and your CDN cache (like Cloudflare).

  3. Fix Cookie Whitelisting: If you are using server-level caching, ensure that the WooCommerce session cookies are whitelisted and bypass the cache entirely. The essential cookies to exclude are:

    • woocommerce_items_in_cart

    • woocommerce_cart_hash

    • wp_woocommerce_session_

  4. Check WooCommerce Status: Go to WooCommerce > Status > Tools and run the Clear WooCommerce transients and Clear expired transients options to reset database-level session storage.