用最低价格替换WooCommerce变量产品的价格范围

问题描述 投票:1回答:1

通过我的Woocommerce网上商店,我使用可变产品销售服务,我想用“价格从最低价格开始”替换价格范围。

我试过在很多方面改变代码,但我没有让它工作。

如何隐藏Woocommerce中的价格范围并仅显示可变产品中的最低价格范围?

php wordpress woocommerce product price
1个回答
0
投票

以下内容将以“价格从最低价格开始”替换可变价格范围:

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

© www.soinside.com 2019 - 2024. All rights reserved.