我们目前在我们的网站上有 WooCommerce 插件的售罄徽章,但我需要能够隐藏特定类别产品上的“售罄”徽章 - 历史轴。有没有办法做到这一点?
原始代码
/**
* Hide Sale badge if product is out of stock
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @param string $content
* @param array|null|WP_Post $post
* @param false|null|WC_Product $product
*
* @return mixed|null
*/
public function hide_sale_flash( string $content, $post, $product ) {
global $post, $product;
return ( carbon_get_theme_option( 'wcsob_hide_sale_flash' ) && ! $product->is_in_stock() ) ? null : $content;
}
认为除了 in_stock 之外我还可以添加 product-category/historical-axes/ 吗?
/**
* Hide Sale badge if product category is historical-axe
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @param string $content
* @param array|null|WP_Post $post
* @param false|null|WC_Product-Category $product-category
*
* @return mixed|null
*/
public function hide_sale_flash( string $content, $post, $product, $product-category) {
global $post, $product, $product-category;
return ( carbon_get_theme_option( 'wcsob_hide_sale_flash' ) && ! $product->is_in_stock, is_product-category/historical-axes() ) ? null : $content;
}