Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
WooCommerce - Show min - max prices for variations, rather than the min price only
* 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;

Is there any way to display a specific variation price instead of the min/max price? For instance I have three variations attached to each product, could I specify one to display?


Hello Mike Jolley. I'm terrible at coding. I need your help, though not too much of it as I suspect it will be easy for your powerful brain.

All I want to do is display ONLY the max_variable_price. Can this filter be amended to do that? I was going to use CSS to display:none using this exact filter but both the min and max values have the same class.

I'd be over the moon if you could help.


@morgyface you just need the:

$price .= woocommerce_price($product->max_variation_price);

part then. Replace lines 10-18 within the function.



If I do as suggested, it removes the option to select between different variables (in my case different price options) on the product. Do you have any suggestion to fix that?



Very useful but doesn't work if product has sale price.


Hi. What if you want to remove the "From" option on the product page all together?


Yes, I am also wondering where the "From" is being generated from. Of course, we can always use CSS to hide it, but you would think it would be fairly easy to find the PHP file generating it and remove it. I have search for hours and with no luck!


By the way, excellent work!


Hi, Mike,

I'm wondering if this code will help me at all
I've added postage options in my variables, so the price shows as from Min variable price.
is there any way to make it show a specific variable e.g. if you look at this shop page :
the price without any extras, or postage is $75, this shows if you select 'no thank you' for the extras, but not initially.
i was hoping to keep the postage options there as woocommerce isn't being very friendly with displaying them on checkout. my only option at the moment is to remove them.


@angryoaf If you want it to do both non-sale and sale items, add a second add_filter() with this:

add_filter('woocommerce_variable_sale_price_html', 'custom_variation_price', 10, 2);


Great snippet :) It was very helpful in getting the "From: min_price" back after 2.1.1. Do you happen to have a similar solution for Product Bundles?


HI works for me however on variable products it has somehow hidden my exc. VAT and inc. VAT text?
I add the exc. VAT and inc. VAT text via the tax tab in woocommerce settings under price display suffix: code below:
exc. VAT | {price_including_tax} inc. VAT

Any ideas? really need this to show!


Same issue here. how to show the "Price display suffix" set in the Woocommerce settings?


Awesome! Very helpful.. thanks Mike!


Someone know how to show the price of variable products even if they have the same price?
Here one with differents prices (make any combination):
And one who have the same price for all variations (this is the one who i need to show the price):

(sorry for my english)


Code is working perfectly! Thanks a ton!

Just a quick question, is there an easy way to show From Price?
Like: Fra 99,95 Kr.

Fra = From in Danish.


To only show min. price including tax, Replace lines 10-18 within the function by

$price .= woocommerce_price($product->get_price_including_tax());


@donsokoli is it possible by adding a ':before' selector with css. e.g:

.price del:before{
content: "Fra";

with that code on your price, is it possible to show the label before the price ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.