My pleasure! I haven’t tested this yet, but it should work. Basically using the filter already in place for the exclude page option, but utilizing the is_woocommerce
conditional. Check out WooCommerce’s documentation on their built-in-conditionals (if this only occurs, for instance, on single product pages you might use is_product()
instead).
I’ve wrapped it in a function_exists
just in case you deactivate WooCommerce in the future and leave Scripts-To-Footer in place, so if you decide to go with a different WooCommerce conditional, be sure to change it in both places.
Place this in your theme’s function.php file or a custom plugin:
function stf_exclude_on_woocommerce( $exclude_page, $post_id ) {
if( function_exists( 'is_woocommerce' ) ) {
if( is_woocommerce() ) {
$exclude_page = 'on'; // this turns on the "exclude" option
}
}
return $exclude_page;
}
add_filter( 'scripts_to_footer_exclude_page', 'stf_exclude_on_woocommerce' );
Let me know if that doesn’t work or if you have any other issues.
Cheers,
Joshua