How to Change the Variable Product Price Range in WooCommerce

If your variable product has a range of prices for it’s variations, then WooCommerce will display this as (for example):

$12.99 - $30.99

Sometimes, this is less than ideal. Fortunately, it’s simple enough to change this to the following format:

From: $12.99

If you’re not sure where to put this code, you can try using the Code Snippets plugin, or add it to your theme or child theme’s functions.php file.

You can easily change the “From: ” prefix by modifying the $prefix variable in the function. To remove it completely, just change it to $prefix = '';

Want to take this a step further?

Try the 14-day free trial of WooCommerce Show Single Variations and display product variations in your WooCommerce shop pages as though they were simple products.

Get Free Trial

Leave a Reply

60 Comments on "How to Change the Variable Product Price Range in WooCommerce"

avatar
  Subscribe  
newest oldest most voted
Notify of
Ivy K.
Guest

I added this code and my whole website is blank now.

It’s certainly done!

jh.
Guest

Maybe you copied the code from IE Edge. Open this site with Firefox to copy the code.

Erik
Guest

This is exactly what I was looking for, Thanks! But when added the code in my child themes function.php the price looks like this: “From: 116,118kr0kr”. Any suggestions?

Mireille
Guest

Is it possible to make the “from” smaller than the price and a different color?

Narelle Eustace Holly
Guest
Narelle Eustace Holly

Using woocommerce currency switcher, the pricing shows 0.00 when using another currency other than the base currency???

Anyway of fixing this???

Michael
Guest

Works just fine with Aelia Currency Switcher

Concerned Citizen
Guest

Thanks for this. Needed the opposite numbers (max vs min) and this did the trick.

Janke
Guest

Hi,
Thank you for the snippet. Is there a way to modify it s it could
also show price without tax? I have set it up in Woocommerce >>
Settings >> Taxes >> Suffixes and for the simple products it
shows well but for the price in this snippet unfortunately not. Do you have some handy idea how to modify your original snippet to show this suffix?
Thanks,
J.

Markus Westerberg
Guest

Hi. I’d also like to know how to fix this.

Michael
Guest

Thank you for the snippet, works just fine.
Could you please advice on how to make prefix to be the same style with the digits? Prefix now is outside that span class.

Elizabeth Drew
Guest

Another great snippet 🙂 This is a goldmine!

Capucine Roussel
Guest

Hello!
I wanted to know how to make this work with your plugin Show Single Variations. At the moment, on the category page the “From : xxx” appears under the original variable product but under the variations, the price of that specific variation appears. I would like the same “From : xxx” to appear under each variation. Can you help?
Thanks!
Just updating my comment as it seems to be pushed down the page by older posts… Any chance you could look into this? Thanks

Barry Johnson
Guest

I added this and it blew up my site. WHERE in the functions.php should it be entered please?

Gudmundur Orn Isfeld
Guest

Hey thanks for the snippet! It is the only one that works with currency converter that I have tried!
My price is showing with a line crossed over it, do you have any idea how to fix that or what it might be?
Thanks again!!! https://uploads.disquscdn.c

Chris Wingfield
Guest

Is this still working for people ? As I’ve added it and I still have the same issue. Many Thanks is advance. PS Flatsome Theme. https://uploads.disquscdn.c

Peter
Guest

Hello,

awesome . But i have a question. On my website also the price per gramm is shown. Like: 12,99 Euro-13,99Euro / kg
How can i edit this so it is also shown like: from 12,99 /kg?

you have a idea?

Thank you very much

Bruno Antunes
Guest

Savior ! 🙂

Jamie
Guest

This code works great! One thing I’m trying to modify that I just cant quite get is I would like this to only happen on the shop and category pages. Then display regularly with the min and max on the single product pages. Is there a simple way to make that happen within the function?

Thanks!

Thomas Strunk
Guest
Wow that worked like a charm! Thank you so much! Do you know how to remove the cents part? Like to have it show only $45 instead of $45.00 ? All of the prices are an even dollar amount without any $44.99 cents or anything like that on the site, so it does not look as clean with the .00 after all of them 😉 They where not on there before so I am guessing there is some part of that code I need to tweak to not have it add that back on there 😉 If you can let… Read more »
Bence Takács
Guest

Displayed correctly on Product Category Pages but on Product Page (if it has variations and it is on-sale) one can see two different prices being displayed: one for the selected variant and one which is the output of the script above.

I can fix that with the following css hack:

div.product-type-variable > div.entry-summary > p.price {
display: none;
}

Rusty Talent
Guest

Thanks!

Igor Dovečer
Guest

Is it possible to update this plugin to only show min prices of available variable products (if variable product stock quantity is >0, otherwise ignore it).
Tnx.

Lorraine Glanz
Guest

I’m battling to customize my WooCommerce site. I struggled with the issue of only showing the lowest price on variable products.
The plugins and other posts have the irritating “from” text before the price, which is just not acceptable to me.
Your post was the first one I came across that dealt with this “from” issue.
Thank you very much. It worked for me.

dzulfriday
Guest

Most of my product only has 2 variants. What if I don’t want to show it differently? Instead of show it like “From: XXX”, I want to show it like this:
– Variant A: $XX.XX
– Variant B: $XX.XX

I don’t want my customers need to use the variant drop down first just to know the price.

Line
Guest

Thank you sooo MUCH

Veronica
Guest

Thank you! Thank you! Thank you!

Coach
Guest

Hi there. Thanks for the code. Works well on my variable product. Is it possible to achieve this “From:” pricing for Grouped product that has simple products linked to it?

Mohsen
Guest

Hello
thank you
I’m looking for a way to show the price of my variable products ” from $ – to $ ” show, not as a straight line, but I do not know what to do.
Thanks for advising me.
Thanks…

Mohsen
Guest

I just want to add “from” and “to” with before the variable price product in this way: from $ – to $ for example : from 20$ to 30$

Mohsen
Guest

Hi
i want show varialbe price like this From $12.99 To $13

how to show this item?

Rocio
Guest

Is there a way to show the Highest Price instead of the Range? For example a restaurant that sells half sizes as an option but wants the Full size to be shown first?

Nate
Guest

Nice snippet man. Thanks for posting.

One note (Flatsome): if a variation is on sale the original price of the variable displays crossed out. Not necessarily a bad thing I guess.

Also for wpml types you can translate ‘from’ here rather than in the translator.

if(ICL_LANGUAGE_CODE==’en’) {

$prefix = sprintf(‘%s: ‘, __(‘From’, ‘iconic’));

}elseif(ICL_LANGUAGE_CODE==’de’){

$prefix = sprintf(‘%s: ‘, __(‘ab’, ‘iconic’));
}

Will Shearer
Guest

Hi, a bit late to the party, but can this be done for a single category? say you have a category of variable pricing where you want “price per person” (let’s call the category “Tours”) then have a category of “gift cards” or something else inanimate with a $prefix of “Prices From”?

Bill
Guest

Thanks, it worked but the suffix “+GST” disappears. Here in Australia we have GST tax, and on our store the prices are given GST exclusive, so we put “+GST” on the end of price. Your script works, but causes the suffix to disappear, can you help a noob out with how to make sure the suffix stays in place after the price?

Chris P
Guest

Awsome mate, finally got a solutio for this. I’ve spend hours looking at various plugins and themes hoping to find one which will do the trick. Turns out I just needed the little snippet of code you provided above!

roberta
Guest

not works if I use dynamic pricing