Woocommerce:显示免费产品的交叉价格

Woocommerce:显示免费产品的交叉价格,woocommerce,Woocommerce,我无法显示0定价可变产品的交叉价格。 这是我的密码。我错在哪里 add_filter( 'woocommerce_get_price_including_tax_html', 'woocommerce_get_regular_price_html', 'woocommerce_get_price_html', 'price_free_zero_empty', 9998, 2 ); function price_free_zero_empty( $price, $product ){

我无法显示0定价可变产品的交叉价格。 这是我的密码。我错在哪里

 add_filter( 'woocommerce_get_price_including_tax_html', 'woocommerce_get_regular_price_html', 'woocommerce_get_price_html', 'price_free_zero_empty', 9998, 2 );

function price_free_zero_empty( $price, $product ){
    if ( '' === $product->get_price_including_tax() || 0 == $product->get_price_including_tax() ) {
$regular_price = $product->get_price_including_tax(); 
        $price = '<del>' . wc_price( $regular_price ) . '</del> '. '<span class="woocommerce-Price-amount amount">'.__("Free", "woocommerce").'</span>';
        
      }
    return $price;
}

add_filter('woocommerce_get_price_include_tax_html'、'woocommerce_get_price_html'、'woocommerce_get_price_html'、'price_free_zero_empty',9998,2);
功能价格\免费\零\空($price,$product){
如果(“”==$product->get_price_include_tax()| 0==$product->get_price_include_tax()){
$regular_price=$product->get_price_include_tax();
$price=''.wc_price($regular_price)。'''.'.'免费',“woocommerce”);
}
返回$price;
}
函数wpgrolify\u price\u free\u zero\u empty($price,$product){
如果($product->get_price()==0){
如果($product->正在销售()&&$product->获得正常价格()){
$regular\u price=wc\u get\u price\u to\u display($product,array('qty'=>1,'price'=>$product->get\u regular\u price());
$price=wc_格式_价格_范围(''.wc_价格($regular_价格)。'',''Omaggio!','woocommerce');
}否则{
$price=''.'.'奥马乔','woocommerce');
}
}
返回$price;
}
添加过滤器(“woocommerce\u get\u price\u html”、“WPGlory\u price\u free\u zero\u empty”,10,2);
function wpglorify_price_free_zero_empty( $price, $product ) {
    if ( $product->get_price() == 0 ) {
        if ( $product->is_on_sale() && $product->get_regular_price() ) {
            $regular_price = wc_get_price_to_display( $product, array( 'qty' => 1, 'price' => $product->get_regular_price() ) );

            $price = wc_format_price_range( '<del>' . wc_price($regular_price) . '</del>', __( 'Omaggio!', 'woocommerce' ) );
        } else {
            $price = '<span class="amount">' . __( 'Omaggio!', 'woocommerce' ) . '</span>';
        }
    }

    return $price;
}

add_filter( 'woocommerce_get_price_html', 'wpglorify_price_free_zero_empty', 10, 2 );