Load “Variation Swatches” CSS forcefully

Blocksy 2’s variation swatches feature is great and lets your visitors quickly glance at the available product offerings, with a visual input that makes their choices easier.

However, if a set of features aren’t detected as enabled, the CSS file for the variation swatches feature won’t load. This was made for performance reasons and also to not load redundant code when it is not needed.

For example, if you use some kind of a plugin to output product cards, and you see that the swatches module is not rendered as it should – you may need to forcefully load the variation swatches CSS.

This can be done with a simple snippet:

add_filter('blocksy:ext:woocommerce-extra:swatches:css', function(){   
return true;
});

Or, you can load the CSS file on a specific page, for example only on the single product page:

add_filter('blocksy:ext:woocommerce-extra:swatches:css', function(){
    if (is_singular('product')) {
        return true;
    }
   
    return false;
});

Please note that this snippet will only work in specific cases, as required by custom implementations.

Not the solution you are looking for?

Please check other articles or open a support ticket.