If you wish to customise how variable product prices are displayed on both the Product Archive and Single Product templates, then this guide is for you. In this example, we remove the dash between the two prices and add the test “From” and “to” for a better user experience. This custom text makes it a little clearer that there are product variations which will determine the price of the product.
/**
* Snippet Name: Customise the price range display of variable products with text
* Snippet Author: ecommercehints.com
*/
add_filter( 'woocommerce_get_price_html', 'ecommercehints_change_variable_price_range_display', 10, 2 );
function ecommercehints_change_variable_price_range_display( $price, $product ) {
if( ! $product->is_type('variable') ) return $price;
$prices = $product->get_variation_prices( true );
if ( empty( $prices['price'] ) )
return apply_filters( 'woocommerce_variable_empty_price_html', '', $product );
$min_price = current( $prices['price'] );
$max_price = end( $prices['price'] );
return apply_filters( 'woocommerce_variable_price_html', 'From ' . wc_price( $min_price ) . $product->get_price_suffix() . " to " . $max_price, $product );
}