用最低价格替换 WooCommerce 可变产品价格范围
Replace WooCommerce variable products price range with the min price
通过我的 Woocommerce 网上商店,我销售使用可变产品的服务,我想用 "Prices starting at" ++ 最低价格替换价格范围。
我尝试过以多种方式更改代码,但都没有成功。
如何在 Woocommerce 中隐藏价格范围并仅显示可变产品的最低价格?
以下将用"Prices starting at"替换可变价格范围为最低价格:
add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );
function custom_variable_price_range( $price_html, $product ) {
$prefix = __('Prices starting at', 'woocommerce');
$min_price = $product->get_variation_price( 'min', true );
return $prefix . ' ' . wc_price( $min_price );
}
代码进入您的活动子主题(或活动主题)的 function.php 文件。已测试并有效。
相关:
通过我的 Woocommerce 网上商店,我销售使用可变产品的服务,我想用 "Prices starting at" ++ 最低价格替换价格范围。
我尝试过以多种方式更改代码,但都没有成功。
如何在 Woocommerce 中隐藏价格范围并仅显示可变产品的最低价格?
以下将用"Prices starting at"替换可变价格范围为最低价格:
add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );
function custom_variable_price_range( $price_html, $product ) {
$prefix = __('Prices starting at', 'woocommerce');
$min_price = $product->get_variation_price( 'min', true );
return $prefix . ' ' . wc_price( $min_price );
}
代码进入您的活动子主题(或活动主题)的 function.php 文件。已测试并有效。
相关: