通过我的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文件中。经过测试和工作。
相关:Replace WooCommerce variable products price range with 'Up to' and the max price