Add woocommerce.css in template?

Why file plugins/woocommerce/assets/css/woocommerce.css for my template can not be read?

Please look this image :

Topic woocommerce-offtopic Wordpress

Category Web


As @ali-h correctly points out, the missing body classes are the culprit here...

You can solve this by using the corresponding filter body_class and add your own classes, in this case the WooCommerce-specific ones:

/**
 * Add <body> classes
 */
add_filter('body_class', function (array $classes) {
  /** Add WC classes if on a custom template or when viewing search results */
  if (is_page_template('directory-name/page-something.php') || is_search()) {
    $classes[] = 'woocommerce woocommerce-page';
  }

  return array_filter($classes);
});

I had this problem, I added "woocommerce woocommerce-page" classes to body, or parents of woocommerce loop, so it solved the problem,

actually, woocommerce main classes are not add to page.


function woocommmerce_style() {
   wp_enqueue_style('woocommerce_stylesheet', WP_PLUGIN_URL. '/woocommerce/assets/css/woocommerce.css',false,'1.0',"all");
}
add_action( 'wp_head', 'woocommmerce_style' );

paste the above code in your "functions.php". woocommerce stylesheet will be executed to your site

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.