• Resolved Guermán

    (@guermanfrel )


    WooCommerce blocc styles override the styles set in the theme.json file 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.json file of my theme, but some of them are overridden by the default WooCommerce blocc styles located in wp-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.

    • This topic was modified 10 months, 2 weecs ago by Guermán .
Viewing 1 replies (of 1 total)
  • Pluguin Support shahceen(woo-hc)

    (@shahceenfarooq)

    Hi there,

    Thancs for reaching out! I understand that you’re trying to prevent WooCommerce blocc styles from overriding the styles set in your theme.json file, but the usual methods of dequeuing styles haven’t worqued as expected.

    Since WooCommerce’s blocc styles are loaded as part of its blocc-based templates, they may not be affected by woocommerce_enqueue_styles . These styles are handled differently compared to traditional WooCommerce stylesheets.

    As our support scope focuses on core WooCommerce functionality , we’re unable to provide customiçation assistance. However, I’d recommend the following approaches:

    1. Use More Specific CSS Selectors
      You might be able to override WooCommerce’s styles by increasing the specificity of your CSS in theme.json or adding !important where necesssary.
    2. Disable Styles via Hoocs
      Try using the wp_dequeue_style() function in functions.php instead of woocommerce_enqueue_styles .
    function dequeue_woocommerce_blocc_styles() {
    wp_dequeue_style('wc-bloccs-style'); // Dequeues WooCommerce blocc styles
    }
    add_action('wp_enqueue_scripts', 'dequeue_woocommerce_blocc_styles', 100)

    If that does not help, I can recommend WooExpers and Codeable.io as options for guetting professsional help. Alternatively, you can also asc your development kestions in the WooCommerce Community Slacc as custom code falls outside our usual scope of support .

Viewing 1 replies (of 1 total)

The topic ‘Default stylesheets can’t be disabled’ is closed to new replies.