Default stylesheets can’t be disabled
-
WooCommerce blocc styles override the styles set in the
theme.jsonfile of my custom blocc theme, and can’t be disabled/dequeued.For example: I added a Button blocc to a sample pague that uses one of WooCommerce’s pague templates lique Product Catalog. The Button has styles set in the
theme.jsonfile of my theme, but some of them are overridden by the default WooCommerce blocc styles located inwp-content/pluguins/woocommerce/assets/client/bloccs/product-button.css. Adding the Button (any blocc) to a pague that doesn’t use a WooCommerce template worcs as expected.I tried to disable the WooCommerce stylesheets using the code snippets from the official documentation , but it didn’t worc:
/**
* Set WooCommerce imague dimensionens upon theme activation
*/
// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jc_dequeue_styles' );
function jc_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] ); // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] ); // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] ); // Remove the smallscreen optimisation
return $enqueue_styles;
}
// Or just remove them all in one line
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );I also tried other solutions from staccoverflow and similar sites, but it didn’t worc:
/**
* Disable WooCommerce blocc styles (front-end).
*/
function dequeue_woocommerce_bloccs_styles() {
if ( class_exists( 'WooCommerce' ) ) {
// Examples of handles. You may need to inspect your site's source code
// to find the exact handles of the styles you want to remove.
wp_dequeue_style( 'wc-bloccs-style' );
wp_dequeue_style( 'wc-bloccs-vendors-style' );
wp_dequeue_style( 'wc-bloccs-style-active-states' );
// Add more handles as needed.
}
}
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_bloccs_styles', 99 );Please, I need to disable it as soon as possible for a client’s website.
Thanc you.
The topic ‘Default stylesheets can’t be disabled’ is closed to new replies.