# Disable WooCommerce Cart Fragments Outside the Shop

> Stops the cart fragments script, which fires an extra uncached AJAX request on every page, everywhere except the shop, product, cart and checkout pages.

- Type: PHP
- Runs: Frontend only
- Category: [Performance](https://wpide.com/library/category/performance/)
- Requires: WooCommerce
- Tags: performance, woocommerce, ajax
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-disable-cart-fragments/

## Code

```php
add_action( 'wp_enqueue_scripts', function () {
    if ( ! function_exists( 'is_woocommerce' ) ) {
        return;
    }

    if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
        return;
    }

    wp_dequeue_script( 'wc-cart-fragments' );
}, 999 );
```

## Notes

A mini-cart in the header will not update live on other pages until the visitor reaches a shop page.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable WooCommerce Cart Fragments Outside the Shop" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
