Stopping Cart Fragments From Updating in WooCommerce

Not too long ago, I had a request through my contact form, regarding additional admin-ajax.php requests that currently are not covered by Heartbeat Control (since Heartbeat Control is meant to stop heartbeat requests, not AJAX requests). The requests he was referring to were caused by his cart fragments being updated and wanted them to stop.

Note: This will stop your cart items from being updated live on the page when adding an item to the cart. The items will be added successfully, but won’t update until the next page load.

add_action( 'wp_print_scripts', 'nuke_cart_fragments', 100 );

function nuke_cart_fragments() {
    wp_dequeue_script( 'wc-cart-fragments' );

    return true;
}

Once again, notice that the entire script is de-queued. See the above note for the consequences of doing this.

Think I’m a super cool guy? Love my beard?

Share this post:

There is one comment

Your email address will not be published. Required fields are marked *