WooCommerce - 隐藏特定类别的售罄徽章

问题描述

我们目前在我们的网站上有 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,$product,$product-category) {
        global $post,$product-category;

        return ( carbon_get_theme_option( 'wcsob_hide_sale_flash' ) && ! $product->is_in_stock,is_product-category/historical-axes() ) ? null : $content;
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)