Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 104029

Default stylesheets can’t be disabled

$
0
0

Replies: 0

WooCommerce block styles override the styles set in the theme.json file of my custom block theme, and can’t be disabled/dequeued.

For example: I added a Button block to a sample page that uses one of WooCommerce’s page templates like Product Catalog. The Button has styles set in the theme.json file of my theme, but some of them are overridden by the default WooCommerce block styles located in wp-content/plugins/woocommerce/assets/client/blocks/product-button.css. Adding the Button (any block) to a page that doesn’t use a WooCommerce template works as expected.

I tried to disable the WooCommerce stylesheets using the code snippets from the official documentation, but it didn’t work:

/**
* Set WooCommerce image dimensions upon theme activation
*/
// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_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 stackoverflow and similar sites, but it didn’t work:

/**
* Disable WooCommerce block styles (front-end).
*/
function dequeue_woocommerce_blocks_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-blocks-style' );
wp_dequeue_style( 'wc-blocks-vendors-style' );
wp_dequeue_style( 'wc-blocks-style-active-states' );
// Add more handles as needed.
}
}
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_blocks_styles', 99 );

Please, I need to disable it as soon as possible for a client’s website.

Thank you.


Viewing all articles
Browse latest Browse all 104029

Trending Articles