DevHub Logo
Home/Blog/WooCommerce Cart Not Updating

WooCommerce Cart & Checkout Broken After Hosting Migration? Autoptimize 'Optimize Cart' Setting to Blame (2025 Fix)

Motions Studio Team

July 9, 2026

6 min read
WooCommerce cart issue

WooCommerce Cart & Checkout Broken After Hosting Migration? Autoptimize 'Optimize Cart' Setting to Blame (2025 Fix)

After migrating a WooCommerce store to a new host, you may find that the cart and checkout pages stop working. The symptom often looks like: the 'Add to Cart' button does nothing, the cart page shows an empty cart even after adding items, or the checkout page fails to load and redirects to the homepage. This is frequently caused by the Autoptimize plugin aggressively caching the cart and checkout pages. Autoptimize, by default, enables the 'Optimize cart/checkout' option, which applies JavaScript and CSS aggregation to these critical pages. During a migration, the caching layer may conflict with the new server environment, session handling, or permalink structures, leading to broken functionality. The fix is straightforward: disable the 'Optimize cart/checkout' setting in Autoptimize. Alternatively, you can use code to forcefully exclude these pages from optimization.

Step-by-Step Solution

  • 1Go to Settings > Autoptimize in your WordPress admin.
  • 2Under the 'JavaScript' and 'CSS' tabs, look for the 'Optimize cart/checkout' option and uncheck it.
  • 3Click 'Save Changes and Empty Cache'.
  • 4Clear any additional server or CDN cache (e.g., LiteSpeed Cache, Cloudflare).
  • 5Test the cart and checkout pages by adding a product and proceeding through checkout.
  • 6If the issue persists, add the PHP code snippet above to your theme's functions.php or via a code snippet plugin.
  • 7If you still experience problems, temporarily deactivate Autoptimize to confirm it's the source.
  • 8After fixing, consider excluding cart and checkout from all caching plugins (e.g., WP Rocket, W3 Total Cache).
// Add to your theme's functions.php to disable Autoptimize on cart and checkout
add_filter('autoptimize_filter_js_exclude', 'exclude_cart_checkout_from_autoptimize', 10, 1);
add_filter('autoptimize_filter_css_exclude', 'exclude_cart_checkout_from_autoptimize', 10, 1);

function exclude_cart_checkout_from_autoptimize($exclude) {
    if (function_exists('is_cart') && is_cart()) {
        $exclude[] = 'cart';
    }
    if (function_exists('is_checkout') && is_checkout()) {
        $exclude[] = 'checkout';
    }
    return $exclude;
}

Final Recommendation

Best Practice

For long-term stability, always exclude the cart, checkout, and My Account pages from any caching or minification plugin. Autoptimize's 'Optimize cart/checkout' option can cause conflicts during server migrations, updates, or when using third-party payment gateways. Use the code snippet above as a bulletproof measure. Additionally, regularly test your checkout flow after any significant hosting or plugin update to catch regressions early.

WooCommerce Fixes
Share this guide
M

Motions Studio Team

WordPress developer specializing in debugging, WooCommerce optimization, and PHP compatibility fixes.