我正在使用此代码段将 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,00Free
$regular_price = wc_get_price_including_tax( $product->get_regular_price());
$sale_price = wc_get_price_including_tax( $product->get_sale_price());
然后附加到 $price。
我该如何解决?