Woocommerce:显示 0 个定价可变产品的正常价格

时间:2021-05-25 12:30:58

标签: woocommerce

我正在使用此代码段将 0 price 替换为自由文本:

/**
* @snippet       Display FREE if Price Zero or Empty - WooCommerce Single Product
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 3.8
* @donate $9     https://businessbloomer.com/bloomer-armada/
*/
  
add_filter( 'woocommerce_get_price_html', 'bbloomer_price_free_zero_empty', 9999, 2 );
   
function bbloomer_price_free_zero_empty( $price, $product ){
    if ( '' === $product->get_price() || 0 == $product->get_price() ) {
        $price = '<span class="woocommerce-Price-amount amount">FREE</span>';
    }  
    return $price;
}

我也需要显示正常价格。 我的目标是显示

1.000,00 Free
我试图在这个片段中添加变量:

$regular_price = wc_get_price_including_tax( $product->get_regular_price());

$sale_price = wc_get_price_including_tax( $product->get_sale_price()); 然后附加到 $price。

我该如何解决?

0 个答案:

没有答案