Replace WooCommerce variable products price range with the min price

后端 未结 1 523
鱼传尺愫
鱼传尺愫 2021-01-24 11:58

With my Woocommerce webshop, I sell services using variable products and I would like to replace the price range by \"Prices starting at\" ++ the lowest price.

I have t

相关标签:
1条回答
  • 2021-01-24 12:23

    The following will replace the variable price range by "Prices starting at" with the lowest price:

    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 );
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.

    Related: Replace WooCommerce variable products price range with 'Up to' and the max price

    0 讨论(0)
提交回复
热议问题