Home / Blog / WooCommerce: Display Price For Variable Product With Same Variations Prices

WooCommerce: Display Price For Variable Product With Same Variations Prices

Recently, I was asked to add a few variations to a product in WooCommerce eCommerce system. I added two attributes with different options to create the variations. The product needed to display the same price, no matter which variation is selected by customers. That sounds simple right? Yes, but by default, WooCommerce product page does not display the price if a variable product has many variations with the same prices. This is because the minimum and maximum prices are the same. Fortunately, you can force it to display the price by add the following snippet to your functions.php file.

// Display Price For Variable Product With Same Variations Prices
add_filter('woocommerce_available_variation', function ($value, $object = null, $variation = null) {
	if ($value['price_html'] == '') {
		$value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
    return $value;
}, 10, 3);




Tags: ,

  • Evens Goddard

    excelent! you don’t now how much I had to look for this fix.

  • Jacek ‘Ravager’ Siedlaczek

    Hi there! I tried this solution, but when i paste the code into functions.php it crashes the site. Have You encountered this bug before?

  • Phe Le

    Hi Jacek, I have not seen that error before. It could be that you accidentally replaced/removed inside your functions.php. Also, check for the semicolons.

  • http://banhangusa.com/ Ku Tún

    Thanks @phele:disqus, you’ve save my day. 😉

  • http://www.ivandude.com Ivandude

    Thanks, this has helped me too.

  • Jacek ‘Ravager’ Siedlaczek

    After few attempts, still cant get this to work and its really important for me now. Can I upload You my functions.php file, so You can see if there are no mistakes there?

  • Marc Rey

    Thanx a lot! Helped a great deal. Woothemes should implement that functionality by default though.

  • tqhung85

    Thanks so much! It is an important part in my project. A headache issue is solve, you saved my day!


    It’s very useful for me

  • UnuAltu

    Be careful, this only works if you have at least php 5.3 on server, on 5.2.17 does not work!!!

  • Tosh Mitsu

    Hi there,
    this worked… Great!

    It seems though that the price is showing below my drop downs (is this because of where I have pasted the code?)

    Also, it shows the price on a product detail page, but is there a way of showing the price when we see a product list?

    Thanks for sharing this :)

  • Miguel Ángel

    Thank You!

  • Web Dev

    Will this show the price if the variations cost differently?

  • Phe Le

    I think by default, it shows the price if the variations prices are different.

  • Cristiano Martins Rodrigues

    Works for me thanks, but how show the price in sub-menu pages, and the price in product page just apear when click in variation and the both prices are the same.

  • Alap Pg

    Excellent its work for me thank you.. solve my issue…

  • kitsudo1412

    Thank you so much! This saved me tons of time.

  • http://www.kupodivu.cz/ Kupodivu

    Great, thanks so much!

  • mahesh

    Great, thanks so much!

  • Harry J.G. Lieferink

    Hi, I added it to the functions.php off the avada theme directory but there is no difference. Should I put it somewhere specific in the functions.php?

  • Raju Kumar Sharma

    great work saved me i was doing using javascript .

  • DodgeThat

    This works Perfect!!!! Thank you!

  • Phe Le

    Wow, I’ve had this issue more than three years ago. I’m glad that it still help everyone else.

  • Rocker

    Thank you very much! You are the Master of Woocommerce :)

  • Babalot Govoseye

    thank you so much! i was having a headache this morning trying to display the price for a product.

    but… is it me or this is a 4 years old unfixed bug? it’s not a clearly “feature” not to display the price for the end user…