Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created June 19, 2023 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/29ae87f7bd98eb28e4bd190e47d3c0f1 to your computer and use it in GitHub Desktop.
Save lukecav/29ae87f7bd98eb28e4bd190e47d3c0f1 to your computer and use it in GitHub Desktop.
Executive the cart-fragments script only on specific pages in WooCommerce
add_filter( 'woocommerce_get_script_data', function( $script_data, $handle ) {
if ( 'wc-cart-fragments' === $handle ) {
if ( is_woocommerce() || is_cart() || is_checkout() ) {
return $script_data;
}
return null;
}
return $script_data;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment