WooCommerce - 如何防止 Storefront 在子主题的样式表之后加载 woocommerce.css

WooCommerce - How to prevent Storefront from loading woocommerce.css after the child theme's stylesheets

我正在使用 WordPress 4.7、Storefront 2.1.6 和我自己的 Storefront 子主题开发 WooCommerce 商店。 但是 Storefront 似乎在我的子主题的 css(编译的 scss)之后加载了一个 woocommerce.css,所以它覆盖了我的一些样式。使用 '! important' 在所有这些样式上对我来说似乎是一个肮脏且不可接受的解决方案。有没有办法阻止 Storefront 加载 woocommerce.css 或加载我自己的样式作为最后一个样式表文件?

感谢

add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );

https://docs.woocommerce.com/document/disable-the-default-stylesheet/

我遇到了同样的问题,我需要对所有内容使用 !important。

所以我查看了源代码,可以看到我的样式表是在 woocommerce 的样式表之前加载的。

(我正在使用我自己的儿童主题,我使用的是 WP 5.5.1 和 WooCommerce 4.5.2)

我发现 WooCommerce 使用优先级为 10 的挂钩加载样式表。

add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ), 10 );

所以我将 functions.php 中的样式表挂钩更改为优先级 11。因此它会稍后加载。

add_action( 'wp_enqueue_scripts', 'fitcoach_scripts', 11);