Categories: WooCommerce Tutorials, Tips and GuidesWordPress Tutorials, Tips and Guides

How to Change Variable Product Price Range in WooCommerce

Reading Time: 2 minutes

Before WooCommerce 2.1, the range of the prices for products were not displayed. Thus instead of showing “From  55-60”, the price showed up as “Starting from  55”.

In many cases, the store owners do not wish to display the full range of price. However, this is no longer the option in the newer versions of WooCommerce.


To implement this, you need to add the following code snippet to the functions.php of your theme. This file is located in the theme folder.

function cw_prc_varb( $val_price, $product ) {

    $prefix = sprintf('%s: ', __('From', 'through'));
    $cw_reg_min_prc = $product->get_variation_regular_price( 'min', true );
    $cw_min_sale_prc    = $product->get_variation_sale_price( 'min', true );
    $cw_prc_max = $product->get_variation_price( 'max', true );
    $cw_prc_min = $product->get_variation_price( 'min', true );

    $val_price = ( $cw_min_sale_prc == $cw_reg_min_prc ) ?
        wc_price( $cw_reg_min_prc ) :
        '<del>' . wc_price( $cw_reg_min_prc ) . '</del>' . '<ins>' . wc_price( $cw_min_sale_prc ) . '</ins>';

    return ( $cw_prc_min == $cw_prc_max ) ?
        $val_price :
        sprintf('%s%s', $prefix, $val_price);


add_filter( 'woocommerce_variable_sale_price_html', 'cw_prc_varb' );
add_filter( 'woocommerce_variable_price_html', 'cw_prc_varb' );



In this tutorial I have discussed how you could easily change the present behavior of  the display of the price range on WooCommerce stores. If you need any help with the implementation of this idea, do leave a comment below.

Owais Alam :is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at owais.alam@cloudways.com