WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on an online store using Woocommerce, many products have variations in size and price. Is there a way to have the range of prices (highest to lowest) of the variations on the product page?

share|improve this question
can we see the code displaying your variations? – Tom J Nowell Mar 25 '13 at 13:57
up vote 3 down vote accepted

try it like this:

* 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;

source: https://gist.github.com/mikejolley/1600117

share|improve this answer

Stumbled upon this thread looking for the same solution for Grouped products. Eventually wound up with the code below... so I'm posting it if it helps others. This will not work for variable products, just grouped. Figured this would be relevant since grouped/variable products are fairly similar and I thought others might also stumble upon this thread. You could probably clean up the span some but this is the quick and dirty version that got me going!

/*** Returns Price Range for Grouped Products**/
function wc_grouped_price_html( $price, $product ) {
$all_prices = array();

foreach ( $product->get_children() as $child_id ) {
    $all_prices[] = get_post_meta( $child_id, '_price', true );

if ( ! empty( $all_prices ) ) {
    $max_price = max( $all_prices );
    $min_price = min( $all_prices );
} else {
    $max_price = '';
    $min_price = '';

$price = '<span class="from">' . _x('From: ', 'min_price', 'woocommerce') . woocommerce_price( $min_price ) .  _x(' to ', 'max_price', 'woocommerce') . ' </span>' . woocommerce_price( $max_price );

return $price;
add_filter( 'woocommerce_grouped_price_html', 'wc_grouped_price_html', 10, 2 );
share|improve this answer

Woocommerce gives you the option to create variable products http://wcdocs.woothemes.com/user-guide/product-variations/

share|improve this answer
You misunderstand. I can do this just fine. I simply want to display "from (lowest cost) to (highest cost)" – Btuman Oct 22 '12 at 5:06
@mirage this answer would become useless if woothemes changed their URL, a link answer is thus not an appropriate answer. Extract the relevant details from the page at the other end and incorporate them into an answer that can be understood by itself – Tom J Nowell Mar 25 '13 at 13:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.