Created
June 19, 2023 20:28
-
-
Save lukecav/29ae87f7bd98eb28e4bd190e47d3c0f1 to your computer and use it in GitHub Desktop.
Executive the cart-fragments script only on specific pages in WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
https://developer.woocommerce.com/2023/06/16/best-practices-for-the-use-of-the-cart-fragments-api/