By default WooCommerce shows minimum and maximum price values for grouped products. However, it still shows range of price when the range doesn't exist (e.g. $55 - $55). This is very ambiguous and unnecessary.
Is it possible to hide the dash and higher value when the minimum and maximum prices are the same?
This code should be added to functions.php of your theme
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
function custom_variation_price( $price, $product ) {
$price = '';
if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
$price .= woocommerce_price($product->get_price());
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
$price .= '<span class="to"> ' . _x('to', 'max_price', 'woocommerce') . ' </span>';
$price .= woocommerce_price($product->max_variation_price);
}
return $price;
}
I've found the problem. The feature I wanted is present by default but for some reason the paid plugin "WooCommerce Prices By User Role" turned it off. It came back when I turned the plugin off.