在我的WooCommerce网络商店中,我使用可变产品销售服务,我想以"以" 的价格替换价格范围。
我尝试以多种方式更改代码,但我没有工作。
我如何隐藏wooCommerce中的价格范围并仅显示可变产品上的最低价格?
以下将以最低价格从"开始"的价格替换可变价格范围:
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变量产品价格范围为"最高"和最高价格