Website Building » WooCommerce » How Do I Disable Cart Fragments in WooCommerce?

How Do I Disable Cart Fragments in WooCommerce?

Last updated on January 18, 2023 @ 1:39 pm

WooCommerce is a popular eCommerce platform for WordPress. One of its features is the ability to add “fragments” to the shopping cart.

These fragments are small pieces of code that are used to improve the functionality of the shopping cart. However, some users may want to disable cart fragments for various reasons. In this article, we will show you how to disable cart fragments in WooCommerce.

What are Cart Fragments?

Cart fragments are small pieces of code that improve the functionality of the WooCommerce shopping cart. They are used to update the cart total and number of items without refreshing the page. This can provide a better user experience for your customers.

Why Would I Want to Disable Cart Fragments?

There are a few reasons why you may want to disable cart fragments in WooCommerce. For example, if you are using a caching plugin, then fragments can cause issues with the caching. Another reason is if you are having issues with your server resources due to the extra load that fragments can cause.

PRO TIP: If you are planning to disable cart fragments in WooCommerce, please be aware that this could potentially break your store’s checkout process. Cart fragments are responsible for keeping track of items in the shopping cart, and without them, your customers may not be able to complete their purchase. Proceed with caution and test thoroughly before making any changes to your live site.

How to Disable Cart Fragments in WooCommerce

Disabling cart fragments in WooCommerce is fairly easy to do. You just need to add a single line of code to your theme’s functions.php file or a site-specific plugin.

add_filter( 'woocommerce_update_order_review_fragments', '__return_false' );

This code will disable all cart fragments in WooCommerce. If you only want to disable specific fragments, then you can use this code:

add_filter( 'woocommerce_cart_fragments_{fragment}', '__return_false' );

(replace {fragment} with the name of the fragment you want to disable).

Kathy McFarland

Kathy McFarland

Devops woman in trade, tech explorer and problem navigator.