WooCommerce: Disable Variable Product Price Range $$$-$$$

You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case).

With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the same time, variable products with a single price (i.e. all variations have the same price) will keep their original format, so won’t display the “From: ” prefix.

Simply paste the following code in your child theme’s functions.php and enjoy!

WooCommerce: disable the variable product price range

PHP Snippet: Change WooCommerce Variable Product Price Range Format to “From: min_price”

This version is also compatible with other plugins that edit product prices (such as Dynamic Pricing). This snippet will display a single price, which is the lowest of all prices, including sale prices.

This snippet won’t change the format of variable products with a single price (when all variations have the same regular price).

/**
 * @snippet       Variable Product Price Range: "From: min_price"
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 8
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'woocommerce_format_price_range', 'bbloomer_variation_price_format_min', 9999, 3 );

function bbloomer_variation_price_format_min( $price, $from, $to ) {
   return wc_get_price_html_from_text() . sprintf( _x( '%1$s', 'Price range: from', 'bbloomer' ), is_numeric( $from ) ? wc_price( $from ) : $from );
}

Advanced Plugin: WooCommerce Variation Prices

In case you don’t want to edit code on your site, I also researched plugins that let you disable the variation price range.

The best option is WooCommerce Variation Prices, which comes with a choice of pre-built formats or the ability to create your own. For example, you could display the price as “From XXX”, “To XXX”, list each variation price separately, and so on.

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]
  • WooCommerce: How to Remove the “Default Sorting” Dropdown
    If the WooCommerce product sorting functionality (“Default Sorting” dropdown) is a waste of space or you don’t need that select box at all, you may want to remove it. No matter if you prefer custom code or a simple plugin – hiding the product sorting dropdown is a piece of cake. Enjoy!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

469 thoughts on “WooCommerce: Disable Variable Product Price Range $$$-$$$

  1. Hi there!

    First off – many thanks Rodolfo for sharing your knowledge – Business Bloomer is my go to destination for Woo/php related questions.

    Now back to the topic – I was thinking that this snippet might solve the following problem but it did not, so I’m sharing in hopes that someone will chime in or might have come across similar challenge:

    We’re using ‘high to low’ sorting in our shop and we have lots of variable products. With ‘high to low’ sorting the variable products are sorted by the most expensive variation price eg:

    100
    70-90
    80

    and we’re looking for a solution that would make sorting from high to low take into account the lowest variation price so the example above would look like so:

    100
    80
    70-90

    I’ve searched quite extensively and didn’t find any solution though it seems that I’m not the only one in need of such functionality. Any thoughts on the above will be greatly appreciated.

    1. Hello Jacek, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. I also have a better solution to keep the sale price:

    
    add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_sale_price', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'custom_variable_sale_price', 10, 2 );
    
    function custom_variable_sale_price( $price, $product ) {
        $variation_ids = $product->get_children();
        
        $min_regular_price = null;
        $min_sale_price = null;
    
        foreach ( $variation_ids as $variation_id ) {
            $variation = wc_get_product( $variation_id );
            $regular_price = $variation->get_regular_price();
            $sale_price = $variation->get_sale_price();
    
            if ( $regular_price !== "" && ( $min_regular_price === null || $regular_price < $min_regular_price ) ) {
                $min_regular_price = $regular_price;
            }
    
            if ( $sale_price !== "" && ( $min_sale_price === null || $sale_price < $min_sale_price ) ) {
                $min_sale_price = $sale_price;
            }
        }
    
        if ( $min_sale_price !== null && $min_sale_price !== $min_regular_price ) {
            $price = '' . wc_price( $min_regular_price ) . ' ' . wc_price( $min_sale_price );
        } elseif ( $min_regular_price !== null ) {
            $price = wc_price( $min_regular_price );
        }
    
        return $price;
    }
    
    
  3. Hi, I have a question, ok maybe two. I used your snippet with slight modification and activated it on my site using the Code Snippets plugin. My goal was to ignore the first variation in the pricing span display (I sell fabrics and for each fabric I sell, I have swatches available. This is variation #1. However, I don’t want all my fabrics to say “From: $3.00” because to me, that looks like a scam or really bad click-bait. Instead, I want all the “From: $xxx” fields to pick up from Variation #2.).

    However, it is working BEAUTIFULLY on category display pages but it’s not working on the Shop Page or on WooCommerce Blocks.

    Thoughts? What am I missing? Thank you!

    add_filter( 'woocommerce_variable_price_html', 'custom_variation_price_format', 9999, 2 );
    
    
    function custom_variation_price_format( $price, $product ) {
    
        // Get available variations and their IDs.
        $variations = $product->get_available_variations();
        $variations_id = wp_list_pluck( $variations, 'variation_id' );
    
        // Check if there are more than 2 variations to avoid having $min_price being 0.
        if ( count( $variations_id ) > 2 ) {
            $prices = $product->get_variation_prices();
            asort( $prices );
            $min_reg_price = next( $prices['regular_price'] );
            $max_reg_price = end( $prices['regular_price'] );
    
    			$price = wc_price( $min_reg_price ) . ' – ' . wc_price( $max_reg_price );
    	}
        return $price;
    }
    1. Sorry for the delay Maria!

      My fear is that WooCommerce blocks don’t use the “woocommerce_variable_price_html” filter. Are you able to disable all plugins temporarily except WooCommerce, keep the snippet, and see if it works on the default shop page / single product page / and product shortcodes?

      1. I’m not sure you could have been faster at replying. Anyway, in my staging environment, I disabled all as asked.

        Home page: They were already inserted as shortcodes. New and On Sale are still showing the $3.00. Browse all products shows up correctly (omits $3.00 when possible).

        Product Category page: works perfectly
        Single Product page: works perfectly
        Shop Page: works perfectly

        Thank you!

        1. Great! What do your “New” and “On Sale” shortcodes look like please?

          1. The “new” is [recent_products] and “on sale” is [sale_products]

            1. They’re old WooCommerce shortcodes, so you should try with the new version. Try with [products limit="4" columns="4" orderby="id" order="DESC" visibility="visible"] for latest products and [products limit="4" columns="4" on_sale="true"]

              Let me know!

              1. You are a genius! Thank you!!!!!

  4. Hi,

    I tried your ‘PHP Snippet 1’ and is working fine, except that is changing all the prices. I have prices like ‘$$$’ and some ‘$$$ – $$$’.
    I want to change only for these ‘$$$ – $$$’.
    Can you help me, please?

    1. You’re right, please try the new version

  5. Hi,

    I used your code to show From: prices, and it worked well.. but my WPML plugin couldn’t find/translate this From: to other languages, so I want to go back to the standard $$$-$$$ format. I played around with removing the ‘From:’ text and more, but now when I remove the code entirely, the shop-page is totally confused. Some products says ‘From:’ others $$$-$$$. All the single product pages are updated correctly.

    I’ve cleared cache with WP Rocket to no help. Every time I clear cache, different products have the error. I’ve also tried deactivating WP rocket..

    Any idea how I can reset this confusion somehow? I have a very limited functions.php file, but seems like my WP system is remembering this php code somewhere 🙁

    1. Hi Asger – sorry to hear that. It’s definitely some sort of cache as when you remove my PHP it should all go back to normal. Check you haven’t added the code twice also. Otherwise, try to see if your hosting has server-side cache, and clear that one as well

  6. Hello Rodolfo,
    Thanks for your snippets (really helpful).
    I want to using your code to show min price frome in-stock variations.
    Let me give an example :
    Product :
    – Var1 : 100$ in-stock
    – Var2 : 130$ in-stock
    – Var3 : 80$ out of stock
    your code show this result: From 80$ Var3
    my target : 100$ Var1

    I want to ignore out of stock variation prices.
    Can you help me?

    1. Hello Roojin, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  7. Hi Rodolfo,

    Thanks for this and all of your other snippets they are very helpful. I would like to append the variation name next to the price so it appears “From: $$ (Small)”. I currently have all of the sizes appended to the end from the below code, but obviously, I only require “Small” the cheapest variation name:

    add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_min', 9999, 2 );
      
    function bbloomer_variation_price_format_min( $price, $product ) {
       $prices = $product->get_variation_prices( true );
       $min_price = current( $prices['price'] );
       $size = $product->get_attribute( 'size' );
       $min_size = current( $size );
       $price = sprintf( __( 'From %1$s', 'woocommerce' ), wc_price( $min_price ).$min_size );
       return $price;
    }

    I hope you can help, thank you so much.

    1. Hi Sean, I think you should use get_available_variations() instead, loop through all variations and find the one with the lowest price. In this way you also have access to attribute values: https://www.businessbloomer.com/woocommerce-display-variations-name-stock-shop-page/

  8. Of the two codes, the first one works just fine for me. But my variable product is currently discounted (I discounted it on the product itself on each variation vs using a plugin to apply a discount). My issue is that my product will only display “From: $399”, which is the discounted price, but won’t show the slashed price as well. So the second code isn’t working for me.

    Worth noting, I’m applying these codes through the Code Snippet plugin, maybe this why it’s not working? But that plugin works great for the first code that removes the price range. Just doesn’t work to show the slashed price too.

    1. Hi Chris, no.2 works for me, it shows the MIN regular slashed and the MIN sale. Do your variations have all the same price?

  9. Hello Rodolfo, and thanks for your post! I use PHP Snippet 2 and for group variables, it works very well unfortunately for multiple variables it gives me a strange sign here is the image: https://ibb.co/JKgQBTg
    I tried multiple solutions but had no luck. Could you please help me?
    I use the Divi theme the site is under maintenance as you want to see the site, I send you the site credentials
    Thanks for everything

    1. Hey Roby! What do you mean by “multiple variables”?

  10. Nice code …. BUT, it’s not fully customized, and i am pretty sure that no one would ever use it in this form. After the installation, i see two prices on the product page (which is useless) Ultimately as a customer you need to see only the lowest price shown on the home and on the shop page only, and to remove the text: From: (as admin etc)

    1. Screenshot please? And which theme are you on?

      1. Hi rodolfo, this code is not work for me.
        I copied your second code in my function.php
        But I have no effect, the price range remains as it was before.

        Thanks.

          1. Even if you temporarily switch off all plugins but Woo and your theme?

  11. Hi all and Ciao Rodolfo,
    can it be a solution to code like this if we need to have the suffix + VAT (iva) at the minimum price?

    $price = sprintf( __( ‘da %1$s + IVA’, ‘woocommerce’ ), wc_price( $min_price ) );

    Thanks for the help
    Luca

    1. Hey Luca, did you test that?

  12. Added this to my child theme’s functions.php and this did nothing. Could this be because of the theme I am using?

    1. Maybe. Try switching theme temporarily and test again

  13. I need help to show selected variation price twice on my product page –
    One on top before variations and on one bottom after variation.
    Please help me

    1. Hello Neha, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  14. I have only 2 variation. So instead of showing $111 – $999 I need to show $111 & $999. How can i replace – sign by &

    1. Hello Ashiq, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  15. Hi,

    On mainpage i can’t get (including tax), on product page looks good!

    I check all comments, and dont find anwser about that.

    1. Not sure Filip, do you use shortcodes or blocks there?

  16. Hey there, this code helped me a lot but what should i code as if i want to change price according to variation. I want it like if we choose any variation it shows the related amount. kindly help.

    1. Hi Zainab, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

      1. I have the same problem. What should i do?

        1. My answer would be the same, sorry

  17. Thank You so much for this amazing code. I almost backed out but finally I found this code and it worked. WOW 😀

    1. Excellent!

  18. Hi. I am using the Rnb WooCommerce Rental & Booking Plugin, and therefor my products are “rental products”, and not Variable Products. I tried the code and it seems to be no difference.
    I am really new to e-commerce and know very little about coding. Is there any way to only show fra “From-price”?

    Thank you, best regards Johannes

    1. Hi Johannes, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

    2. Hi Johannes, were you able to solve this problem? I have the same situation on my end with the same plugin and have no idea how to adopt these code snippets to work well with this plugin. Maybe Rodoflo will be able to provide some guide for that as well.

  19. Is it possible to at a different price to a product within a composite product. I sell pens the pen barrel in a composite product costs x if you buy the pen barrel outside of the composite product it costs y. The price for the barrel individually is more than the price of the peace within the composite product. Is this even possible and if so how would I go about doing this if it’s custom work please contact me as an interested in completing this

    1. Hello Michael, thanks so much for your comment! Yes, this is definitely possible – if you’d like to get a quote, feel free to contact me here. Thanks a lot!

  20. Hi,
    Thanks for sharing these snippets.

    I’m using snippet #1 and it works great.
    https://tremblayly.wpengine.com/product-category/health/therapeutic-herbal-tea-blends

    However, when logged in as a wholesaler, the wholesale price (in place of the regular price on the first line) the “From: $9.99” option does not work – it displays the range. Because you need a wholesale account to view the prices, here’s a screenshot of what happens:
    https://www.dropbox.com/s/fqnblunoviky2gg/price%20format%20change%20lost.png?dl=0

    Can you help with the code to ensure that the “From: $9.99” works again instead of the price range.

    Thank you
    Lyse

    1. Hi Lyse, this works only with default WooCommerce so I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  21. Hi rodolfo and thank you so much for your snippets.
    i have a question for you.

    Is it possible to show the price of the “out of stock” variant? This code works, but if the variant with the lowest price is set to “out of stock” its price is not displayed.

    1. Hi Marcello, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

    2. Did you ever figure this out? Please share your progress.

  22. Hi Rodolfo, Thanks for a great blog!!

    This snippet works great. I was wondering if it’s possible to change font size and color for only the variable price?
    Please have a look at this screenshot: https://cl.ly/247c6efdee3b

    Thank you 🙂

    1. Hi Martin, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  23. Hi. Works fine for me and thanks.
    But the ideal for me is the “from….” prices to hide completely and variable prices displayed in this position. Not below.
    I believe that all this prices are confuse the visor.

    1. Harris, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  24. Hi,
    i´d like to change the word ´from´ to the word ´van´ (my own language) how to that?

    i love this snippet, much better than other snippets around the web, Tanks!

    1. Hi Buick, just change that word inside the snippet 🙂

  25. Hi, first of all, thanks for sharing all these snippets and tips. They are an invaluable asset!

    I was using snippet #1 for a while and it was working great. However, now it only shows the word “From:” and doesn’t show the price anymore. I did update WooCommerce recently so I am wondering if anything was deprecated?

    Thanks!

    1. Hi Derrick, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!

      R

  26. Hey – great site.
    I am having an issue on my site and it is displaying the variable price from high to low which is quite random.
    When I add the code snippet provided here it ends up giving me the price and then the word from.

    Please help?!

    1. It might be you need to fix some CSS?

  27. I have the following problem, if I choose variable products (for different weight) the price is shown from high to low (from 19.95 – 1.95), instead of low to high. How can I reverse this? Because the price should be from low to high as you also indicate in your first sentence (variable product price range which usually looks like $ 100- $ 999).

    Thank you !
    Sander

    1. Hi Sander! Are you using Snippet #2?

  28. One problem with this code is that if you have a product with variations that all have the same price (but may have different colors, for example), it is showing the From: text before the pricing but shouldn’t be in this case. This makes it appear that there are different prices for a product like this when this is not the case.

    Here are some screenshots of my product list and individual product page for a product with multiple color variations but the pricing is the same across the variations so there is no price range for this product:

    Product list: https://snag.gy/BxdpIe.jpg
    Product page: https://snag.gy/HXpZ9f.jpg

    Please adjust your code to account for this. Thank you.

    1. Correct, Jeff – snippet has now been updated. Thanks a lot 🙂

  29. Works great.
    Wondering, if there is a smart way to show the price of default variation for a product instead on category pages?

    1. Chirag, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  30. But, If my variations are same price in some products, this snippet also say for example. From: 15.00$. Can We edit this snippet for only seperator price?

    1. Hello Cavid- thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  31. Would there be any reason why the DEL tags are getting striped out? My site is removing them and the strike through is not showing.

    1. Hey Mario – thanks so much for your comment! It must be somewhere in your CSS – inspect that element, see the CSS rules and in case add custom CSS to remove those rules 🙂

  32. Thank you for this but I don’t work for me. I don’t know why. Maybe cause I’m trying to do this on DIVI theme? Do you maybe know any solutions?

    1. Hello Dejan – thanks so much for your comment! To verify if it’s Divi or not, try disabling Divi for a moment and applying the snippet to a new theme – if it works then yes, it’s Divi’s fault and the snippet would need to be customized 🙂

  33. In woocommerce 3.4.2 the code doesn’t work.
    Could you check it?

    1. Hey Makis, thanks for your comment! Just retested on 3.4.3 and still works 🙂

    2. Ok, so the wordpress Flatsome Template doesn’t support this snippet.
      Could you suggest any solution?

      1. Makis, thanks so much for your comment! Yes, there is a way to make the snippet work with your theme – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  34. Hi there,

    I used a lot of your snippets and tutorials already, great site.

    I’m using this snippet but I want to combine this with your following snippet: https://businessbloomer.com/woocommerce-add-prefix-suffix-product-prices/

    I would like to show only the from price and have de including tax price as suffix. (I can get both to work separately, but not together).

    Any ideas how to get both functions working?

    Regards,

    Dennis.

    1. Hey Dennis, thanks so much for your comment! Yes, this is possible (you would need to work on the “‘From: %1$s'” string and add another argument to it – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  35. Hello,
    Does this work with lastest version of woocommerce?
    Thanks

    1. Hey Roland, it should! Did you try?

    2. No it doesnt change the price range

      1. Could you try with a different theme and no other plugins then WooCommerce please?

  36. Disable WooCommerce Variable Product Price Range $$$-$$$

    Thanks!!! very helpful.

    Please, I only want to make this changes to the category page. Not the single product page.
    How do I still keep the Product range price in Product page only.

    Thank you!!!

    1. Hey Kelechi, thanks so much for your comment! I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know 🙂

  37. Thank you for this awesome code but its not working for me 🙁 unfortunately…

    We use PHP Snippet #1 (Woo 3.1.0+) but there are no changes, we delete cache and edit the function.php file in child theme.
    We have “latest” version WooCommerce : 3.3.5

    Please help!

    1. Hey Blokof, this should work. Try switching theme and disabling all plugins but Woo and see if it works. If not, then you’re right – let me know. If yes, then you have a conflict with another plugin/theme.

  38. Is there a way to do with css instead of changing the php?

    1. I’m afraid not 🙂

  39. Hey Rodolfo,

    Firstly, thanks for sharing this code. It saved me £50 from having to hire a developer to do this for me – really simple guide.

    One thing I am trying to do which I cannot find out how to do – is removing the huge gaps. There’s one huge gap between “From” and the “£” and a smaller one between “£” and the amount. Is there a way to just make it say something like “From £20.00” for example? Without the huge spaces?

    I’m currently using this snippet

    add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_310', 10, 2 );
     
    function bbloomer_variation_price_format_310( $price, $product ) {
     
    // 1. Find the minimum regular and sale prices
     
    $min_var_reg_price = $product->get_variation_regular_price( 'min', true );
    $min_var_sale_price = $product->get_variation_sale_price( 'min', true );
     
    // 2. New $price
     
    if ( $min_var_sale_price < $min_var_reg_price ) {
    $price = sprintf( __( 'from: <del>%1$s</del><ins>%2$s</ins>', 'woocommerce' ), wc_price( $min_var_reg_price ), wc_price( $min_var_sale_price ) );
    } else {
    $price = sprintf( __( 'from: %1$s', 'woocommerce' ), wc_price( $min_var_reg_price ) );
    }
     
    // 3. Return edited $price
     
    return $price;
    }

    Once again, thanks for the snippet!

    1. Hey Stephen, thanks so much for your comment! It must be either your CSS or the wc_price function that is messing with your spacing, as this PHP snippet only adds a blank space after from:

      Hope this helps 🙂

  40. Hi there,

    Is there a way to hide the ranges on the homepage or just every pages except the shop/product pages?

    Thank

  41. Hi everyone!
    I have problems with this php snippets with stripe plugin is activated… and i’m in trouble!! I must use stripe!
    A “undefined” result is shown when i choose variations in front-end!
    Can you help me please?
    Thank you anyway.

    1. Sam, thanks so much for your comment! I just retested this on the latest version of WooCommerce and it still works. Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  42. Hi there,

    We’ve got a client who uses his WooCommerce site to get Product Enquiries, he doesn’t sell online. 99% of his products have prices, however he has a range of products whereby the supplier doesn’t allow him to display a price, this is fine

    However, he’s got some products that have variations so size and Mattress Type. However, this won’t work without setting a price in the Variations as we get this message:

    Sorry, this product is unavailable. Please choose a different combination.

    In the end we can create each one individually but it would be nice to be able to use variations.

    Is that possible at all?

    Thanks,
    Darren

    1. Hey Darren, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  43. Can this be done on grouped products?

    I can’t seem to remove the same price range on a grouped products.

    1. Hay James, thanks so much for your comment! Yes, this can be done, but the code is different – try with this: https://businessbloomer.com/disable-grouped-product-price-range-woocommerce/

  44. Hi Rodolfo,

    i tried your code and it’s works!!

    But when in a variable product there isn’t a sale price, the code show the same price cancelled.

    I would like not show a cancelled price when there isn’t a sale price. It is possible?

    Thank you

    1. Thank you Federico! Which code snippet are you using?

    2. Hey Rodolfo,

      I faced the same issue with PHP Snippet #1 (Woo 3.1.0+). With no sale price on the variation, it was crossed off. This was fixed when i changed the conditional check to

      // 2. New $price
       
      if ( $min_var_sale_price < $min_var_reg_price ) {
      

      Keep this going. Your work has been inspirational and educational. Big fan.

      1. Brilliant! Thanks Vishnu 🙂

  45. Great code to remove the price range display! But I would like to move the variation price to the location where the range was displayed instead of by the add to cart button. Is this possible?

    1. Hey William, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  46. Thanks Rodolfo, I’ve been using these (and other) scripts from you to improve our shop. One recent problem though:

    FEEDBACK / HELP NEEDED
    Since the latest version of Woo Variable products no longer displays the “Price display suffix” (fe: ex. VAT). It still works fine Grouped or Composite Products.

    So I went to this page, noticed a new version of your script and started using that. It does not solve the problem but actually, adds one. Now the price is repeated, with the first one displayed as strikethrough.

    For now, I have the script turned off. As a result, in the overview of products you currently see From-prices (‘Vanaf’ in Dutch) and the old price range. All those are the ones affected.

    Please update your script to work with the latest version of Woo.

    If you need a staging area to test on, I’ll be happy to provide one.

    1. Hey Verdi, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

    2. Thanks for getting back to me Rodolfo. And yes, I just discovered that it’s no longer compatible with Woocommerce Composite Products. If you are willing to add a snippet for Composite users to this page, I’ll be happy to create a staging area for you to test on.

      I also have Snippets installed, so it’s quick and easy to test your script.

      1. Ah, ok, this snippet is only compatible with “normal” WooCommerce products. Change would need to be changed for any custom plugin, so I can’t help here via the comments I’m afraid. Thanks for your understanding 🙂 R

  47. Great job, thanks Rodolfo. How can I make the “From:” be displayed in black? Thanks

    1. Ariel, thanks for your comment! Yes you can achieve that via CSS. Unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  48. Hello Rodolfo!

    Thank you thank you thank you! Works great! Except… THe first and second snippets are both names snippet #1 and one has a title saying it would display From: (min price). The second Snippet #1 shows that it should hide the variable prices, but it shows also from. One of them shows a strikethrough of the price.

    My understanding is that the second would remove the price range in the Shop / Archive page (which is what I was looking for).

    For now I will be using the last one that hides them all, but thought I’d mention this to you in regards to the first 2.

    Thanks a lot for what you do for the community!

    Regards,

    Paul

    1. Thanks Paul 🙂 The first two snippets are called Snippet #1 as they are the same, but they work with different versions of WooCommerce. Just so you know!

  49. Hey, i had the some problem and fixed it with ur nice code help.

    Now it shows only the min price, my question is how can we show the second variaton price instead first (min price) ?

    1. Or i just need the show price as 2x min price. Cuz the min price is a half kilogram of the product. Can we achieve this ?

      1. Yasin, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  50. Works Perfectly! Thank you 🙂

  51. Hi, can you show how snippet 2 should look in full? Thanks.

    1. Hey Jose, thanks for your comment. I removed the snippet and added a link to my “conditional logic” tutorials. Those should help 🙂

  52. Hi Rodolfo,
    this works great but only unless the product has all variations priced the same. For such products, nothing is being displayed!

    1. Slon, thanks for your comment! What version of WooCommerce are you on?

    2. Hi,
      I think it was 3.0.8 at the moment, no customizations to the plugin or templates.

      1. Can you try the latest/revised snippet please? Cheers 🙂

  53. Hey,
    There is a fix code that will not change the strings on the wordpress admin panel? because when I did the change, the range in the woocommerce – products plugin page in the admin panel also changed and it’s shown “From: …” and not the original range “25$ – 54$”

    1. Hey Ram, thanks for your comment! You can use “conditional logic” inside the function to limit the behaviour on the frontend only (by using !is_admin()). I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know 🙂

  54. Hi there,
    thank you Rodolfo very much for your codes.

    I am not sure if I did well, but I tried change just translation for each language like this:

    Source text: %1$s – %2$s [ Price range: From-to ]

    Translated text: From %1$s

    And it is working withouth problems.

  55. This code worked great to get rid of the ‘From: $9.99’ text for my products, but it doesn’t remove the term for recurring subscriptions, in my case: ‘Every 3 months’.
    Without your code, it shows the variable low price:
    ‘From $9.99 Every 3 months’.
    With the code, I’m left with ‘Ever 3 months’.

    Any suggestions to get rid of the ‘Every 3 months’?

    1. Hey Dave, thanks for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R

  56. Hi, I have this snippet on my dev site, it was working fine until i updated both the WP 4.8 core and woo 3.0.8 to latest releases. The snippet I’m using is

    /**
     * @snippet       Disable Variable Product Price Range
     * @how-to        Get CustomizeWoo.com FREE
     * @sourcecode    https://businessbloomer.com/disable-variable-product-price-range-woocommerce/
     * @author        Rodolfo Melogli
     * @compatible    WooCommerce 2.4.7
     */
     
    add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_variation_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format', 10, 2 );
     
    function bbloomer_variation_price_format( $price, $product ) {
     
    // Main Price
    $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
     
    // Sale Price
    $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
    sort( $prices );
    $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
     
    if ( $price !== $saleprice ) {
    $price = '<del>' . $saleprice . $product->get_price_suffix() . '</del> <ins>' . $price . $product->get_price_suffix() . '</ins>';
    }
    return $price;
    }
    
    1. Hey Matt, thanks for your comment! What version were you on before updating? Did you clear the cache after?

    2. Hi, I think the version I was using was Woo 2.7. I have since upgraded to the latest 3.1.0 nd it doens’t work anymore. I have cleared all cache

      1. Try switching to Twentyseventeen theme – does this work?

    3. Tried Storefront and twentyseventeen neither worked.

      1. Matt, I published a new version of the snippet for Woo 3.1.0+. Can you give it a go please?

    4. HI, Sorry but it doen’t work. I have cleared all caches and it still displays as $3,200.00 – $7,000.00 on archive and single pages

      1. If you switch theme temporarily and apply the snippet to that, does it work? This works on my test website with default Storefront theme and default WooCommerce. Let me know 🙂

  57. Hello.
    I want to translate “From:” into Dutch “Vanaf” from the first code. Not sale price. But when i do that i get a http500 error. I have tried your comments from above. But no luck. I am using the latest woocommerce version, and WordPress version.

    1. Hey Idaniel, thanks for your comment! How are you trying to translate the string? Via a plugin or manually?

    2. Hi Rodolfo,
      I tried manually, in functions.php. But not working.
      What to get it working? thanks.

      1. Please paste your code as I have no idea without looking at it 🙂

    3. /**
       * @snippet       Disable Variable Product Price Range
       * @how-to        Get CustomizeWoo.com FREE
       * @sourcecode    https://businessbloomer.com/disable-variable-product-price-range-woocommerce/
       * @author        Rodolfo Melogli
       * @compatible    WooCommerce 2.4.7
       */
      
      add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_variation_price_format', 10, 2 );
      add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format', 10, 2 );
      
      function bbloomer_variation_price_format( $price, $product ) {
      
      // Main Price
      $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
      $price = $prices[0] !== $prices[1] ? sprintf( __(  'Vanaf: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
      
      // Sale Price
      $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
      sort( $prices );
      $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'Vanaf: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
      
      if ( $price !== $saleprice ) {
      $price = '<del>' . $saleprice . $product->get_price_suffix() . '</del> <ins>' . $price . $product->get_price_suffix() . '</ins>';
      }
      return $price;
      } 
      1. Hey Idaniel, I pasted this exact code in my test website and I got no error. Make sure you are not duplicating the function names, you can’t have the same function name twice in PHP. If you enable WP_DEBUG WordPress will tell you what PHP error it’s causing the 500.

  58. Thanks for this code it worked wonderfully. I was wondering if it was possible to make the “from” a bit smaller and a different color than the price. Thanks!

    1. Hey Mireille, thanks for your comment! Sure, that can be done, you will need CSS to achieve that 🙂

  59. Greetings, and thank you very much for the code! I ran into a problem with your presented solution using is_product() to conditionally change (or in my case, remove) the price range only from the product page.

    The trouble is, if the page contains any variable related products or has links to other variable products via WooCommerce shortcodes (aka [product sku="abc123"] ), the code removes the price range from all of them! It makes sense, since they all exist on the product page, but it’s breaking the desired functionality.

    For reference, this is what my function looks like at the moment, tweaked a bit from what you provided:

    function bbloomer_variation_price_format( $price, $product ) {
    	if ( is_product() ) {
    		// Main Price
    		$prices = array( $product->get_variation_price( 'min', true), $product->get_variation_price( 'max', true) );
    		$price = $prices[0] !== $prices[1] ? '' : wc_price( $prices[0] );
    		
    		// Sale Price
    		$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
    		sort( $prices );
    		$saleprice = $prices[0] !== $prices[1] ? '' : wc_price( $prices[0] );
    		
    		if ( $price !== $saleprice && $price !== '' ) {
    			if ( $saleprice !== '' )
    				$price = '<del>' . $saleprice . $product->get_price_suffix() . '</del> <ins>' . $price . $product->get_price_suffix() . '</ins>';
    			else $price = '';
    		}
    	}
    	return $price;
    }
    

    I’m going to keep poking around and see if I can come up with a solution (and I’ll post if I do), but I wanted to post a comment in the meantime in case you have any ideas!

    1. And almost as soon as I posted I figured out a workaround. Not sure if it will work in all cases, but it did in mine – and it was from another post on your page! https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/

      You indicated targeting the Related Products section like so:

      global $woocommerce_loop;
       if ( is_product() && $woocommerce_loop['name'] == 'related' )
      

      This got me partway there, but didn’t take care of the places I was using shortcodes. I then learned that the shortcode also had a defined name in $woocommerce_loop, but the main price range did not. So, I did this:

      global $woocommerce_loop;
      if ( is_product() && ! isset( $woocommerce_loop['name'] ) ) {
      //the rest of my code above
      }
      return $price;
      

      It might not be perfect, but it worked for me. Just sharing in case anyone runs into the same issue or has a better solution!

      1. Awesome stuff, thank you Sarrah!

  60. Thank you .. it worked perfectly for me! Removed the price from the entire site.

    1. Thanks so much for your feedback Lewin!

  61. This comment is being repeated from another thread where I put it incorrectly, also taking the opportunity to add more info. I am using the 3rd variant snippet… And it still removes the prices on everything that has variable pricing, until selecting the variables and then only shows a small price near “add to cart” button… ?

    On the /shop page, it removes all the prices completely on variable products, all I wanted was to show the “from €minimum_price” for variable products. Same on the taxonomy pages, prices are gone. On the single product page, it shows no price until I select all the variables, and then only a small number down next to the add to cart button.

    I am using WP 4.7.4 and the woocommerce I just updated today to 3.0.6, but the issue was the same last week. My theme is Bridge by QODE.

    1. Finally I googled a bit and found a plugin that would do it, but when I went to check the code, it was actually based on your work, so hmm.. credit where credit is due?? It’s not clear to me what has been changed, but it finally works exactly as I hoped on my site, so thank you 🙂

  62. Hi Rodolfo.
    Im trying to use your code but i´m getting no luck with it. I need to display the variable price as “from:” (that i achieved) But i only want to show that on categories pages and modules that i have, on the product page i just want to show the final variable price. Can you please give me some help on how to do this?

    Hope you can help me =)

    Look forward for your reply
    My best regards

      1. Hi Rodolfo. Thank for your answer. I´m still strugglin on this and i simply cannot fix it 🙁
        The code is working almost 100%, it shows the price on category page and on product page it delets the “from: price”, the problem that im having now and that i cannot solve is that when i have the variations with the same prices it simply doesnt show any price. when the prices are different for each variation it works good. The code im using is this:

        /*REMOVE FROM: VARIABLE PRODUCT*/
        add_filter( 'woocommerce_variable_sale_price_html', 'my_variation_price_format', 10, 2 );
         
        add_filter( 'woocommerce_variable_price_html', 'my_variation_price_format', 10, 2 );
         
        function my_variation_price_format( $price, $product ) {
         
        // Main Price
        $prices = array( $product-&gt;get_variation_price( 'min', true ), $product-&gt;get_variation_price( 'max', true ) );
        $price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
         
        // Sale Price
        $prices = array( $product-&gt;get_variation_regular_price( 'min', true ), $product-&gt;get_variation_regular_price( 'max', true ) );
        sort( $prices );
        $saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
         
        if ( $price !== $saleprice ) {
        $price = '<del>' . $saleprice . '</del> ' . $price . '';
        }
        return $price;
        }
        
        
        /*REMOVE PRICE RANGE FROM VARIABLE PRODUCT*/
        add_action( 'woocommerce_before_main_content', 'bbloomer_single_product_pages' );
         
        function bbloomer_single_product_pages() {
         
        if ( is_product() ) {
        
        add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_remove_variation_price', 10, 2 );
        add_filter( 'woocommerce_variable_price_html', 'bbloomer_remove_variation_price', 10, 2 );
        function bbloomer_remove_variation_price( $price ) {
        $price = '';
        return $price;
        }
         
        }}
        
        

        Hope that you can help as i really dont know what to do more.
        Look forward for your reply.
        My best regards

        1. Ricardo, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R

  63. Hi Rodolfo,

    I’ve been trying to get this working with Grouped Products. I see in the comments some people have asked this before, and you wrote to use:

     woocommerce_grouped_price_html 

    I replaced that ontop of this:

     woocommerce_variable_price_html 

    However, what about

     woocommerce_variable_sale_price_html 

    – I’m not sure what to use to replace this, any ideas?

    There is no such hook as:

     woocommerce_grouped_sale_price_html 

    – tried it just incase and dosen’t work

    Thanks

    1. Hey 🙂 I don’t think Grouped Products have a sale price – so I guess the code will need to be changed a lot. Sorry but cannot offer premium support here on the blog – thanks for your understanding 🙂

      1. Ok, but how do you show it without the sales price at least? do you just remove the lines that have the sales price code?

        1. More or less 🙂 You can always try on a test website!

          1. I did and I couldn’t get it to work. I’m confused because you pasted this code for people below down in the comments also asking about grouped products, but does it actually work with your code?

            1. Hey John, as other official fans requested this too, I actually wrote a brand new tutorial dedicated to Grouped Products’ price range. This will be published on April 25th, so hope to help then 🙂

              1. Thanks mate, look forward to reading it!

  64. Hi Rodolfo,
    I used PHP snippet #1 and it works great. Only thing now is I’ve added a currency switcher and any currency outside of my default currency displays as before, i.e. with the variable product price ranges. Any advice please

    1. Neelam, thanks so much for your comment! Yes, this will 100% depend on your specific currency switcher plugin – hence I cannot provide a complementary solution here on the blog. Have you asked the plugin developers already?

      1. Hi, I haven’t yet asked the currency plugin developers but I will do.

          1. Just an update. The problem was with one of the two currency switcher plugins I had installed. I deactivated and deleted one and now your snippet works across currencies 🙂

            1. Thank you for the follow up, great to hear that!

  65. Hello Rudolfo:

    Your code works great, and it looks like you’ve been very helpful to others on small tweaks. So I’m wondering if you can help me.

    I’m using your code snippet, but I only want to use the “From $x” on the catalogue page. On the product pages, I want to have the variable prices work as they do normally (so when they select a drop down option, the price changes).

    I’m currently using Woocommerce 3.0.2. Any ideas?

    1. Hey Jack, thanks for your content! For that, you need to study the concept of “conditional logic”. I have 2 resources for you:

      1) a video lesson: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/
      2) a PHP guide: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/

      Let me know!

  66. Hi Rodolfo, wonderful snippet. However, i noticed that there’s a little issue. I would like to ask if it’s normal or therefore that’s a problem with my theme.

    So the problem is: When the products are on sale the regular price is crossed out in front of the sale price. Everything fine until here.

    But if the product (variation) is not on sale, the regular price is crossed out again in front of the regular price (again). Is this normal with this snippet? I will post a screenshot:

    http://www.academiamusical.com.pt/variations .jpg

    Can you five me some light please?

    1. Hey Ricardo, thanks for your comment! No, this is not normal – very weird. Can you attach a screenshot of your “Product Data” settings for a specific product, so that I can take a look?

    2. I have this very same problem, the regular price is shown as the sale price and crossed before the regular price (again). I’m using the latest version of everything.

    3. Fixed it by replacing the conditional
      if ( $min_var_sale_price ) {

      with

      if ( $product->is_on_sale() ) {

  67. I am trying to use PHP Snippet #1: Disable WooCommerce Variable Product Price Range $$$-$$$

    Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in /home/raisin73/public_html/wp-content/themes/flatsome-child/functions.php on line 18

    I have deactivated all the plugins but to no-avail! Can you point me in the right or any(!) direction

    Thanks!

    1. Hey Johnny, thanks for your comment! By any chance are you running the newest release of WooCommerce, 3.0?

      1. Version 3.0.1 – is that good news or bad news!? 🙂

        1. Ouch – bad I’d say! It means I need to revise the snippet 🙁

          I will let you know, or check back in a few days!

          1. Hey Johnny! I just tested on Woo 3.0.2 and Snippet #1 worked perfectly. Can you test again please?

            1. Hi Rodolfo, i am on 3.02 and it is not working. Thank you

              1. Sorry, i mean the hide all snippet

                1. OMG, i wasn’t paying attention, i was looking for Grouped products price range and google showed me this post, sorry for spamming so manny messages here. I am still looking to disable the price range on grouped products without having to hide it with CSS. Thank you

                  1. Ahah indeed, I was just about to confirm the snippet works for 3.0.2 🙂 Grouped products use a different filter i.e.:

                    woocommerce_grouped_price_html
                    

                    Let me know 🙂

                    1. <3 + :))

                      Buona Pasqua

                    2. Cheers! Same to you 🙂

  68. I’m using the #3 Snippet and it works great for hiding the price for Variable Products on my product-category page! I’d also like to hide the price for Simple Products on the product-category page. I do want the price visible the specific product page for each Simple Product. I can only figure out how to hide the price in both places or display in both places. Can you point me to info on hiding all pricing on the category page and displaying the price on each product page?

      1. Worked perfectly! Thank you very much!

      2. Im not sure where to ask this but have been searching online all day to find out why my price is showing twice when I create a new simple product?

        I installed on another test WP install and it doesnt happen but does on my main website and I have no idea how to stop it (Im not a coder or that techy)

        1. Hey Carol, thanks for your comment! You can try troubleshooting your WordPress website, take a look at this tutorial: https://businessbloomer.com/woocommerce-troubleshooting-mistakes-to-avoid/

          Hope this helps!

          R

    1. I found the answer in another snippet you provided!
      WooCommerce: Hide Prices on the Shop & Category Pages
      All works just as I’d like now!
      Thank you Rodolfo!

  69. Hi Rodolfo, your snippet is working great!, i’m using it to display the product price of distributor and public this is how it looks thanks to your snippet https://puu.sh/u4JCW/be2e381394.jpg, it works with the variable products and it looks great. but i want to show it the same way in products with discount https://puu.sh/u4JBz/847774530b.jpg , is it possible for you to help me please?

    1. Hello Cristian, thanks for your comment! I’m afraid I can’t help this time – this is custom work and unfortunately I can’t provide premium support to free subscribers. Hope this is ok 🙂

      Just for your interest, I just launched https://businessbloomer.com/club/, and the $39 pack would definitely cover your request. Let me know and thanks a lot for your understanding!

      1. Are these scripts still compatible with version 4.7.3?

        1. Hey Walmir, thanks for your comment! They definitely should, so give it a go and let me know 🙂

  70. Hey Rodolfo amazing snippet! Is it possible to show only one price in variable product page? I mean to hide the price range and show the final price of the variation that will change when you change variation. Thanks for your reply!

    1. Thank you Konstantinos! Unfortunately I’m not sure I fully understand your question – can you link to a screenshot if you get a chance? Thanks!

      1. Unfortunately I don’t have a screenshot. Instead of showing “from 100$” I want to show only the actual price of the selected variation. When selecting the cheapest variation it will show 100$, when selecting another it will show 120$ etc. I hope you understand now.

        1. I get it now, thanks Konstantinos 🙂 It already works like that – when you select your product options, price show close to the add to cart. What you want in this case is to hide the price range completely, and I believe one of the snippets provided should achieve that. Let me know 🙂

  71. Hi Rodolfo,

    I had the same issue and now I’ve solved thanks to your advices.

    Many thanks

    1. Awesome, great to hear that! Ciao 🙂

  72. Hi Rodolfo!

    The Woocommerce snippets you have on this site are amazing and saved me a ton of work. Thanks for your hard work!

    I have one question about the first snippet. I used this on a client’s site and it works perfect.
    The thing now is. On some of the sale products it’s displayed as: https://www.globalfurniture-elst.nl/nieuw/product/bowl-salontafel-metaal-hout/ Eerst: € 239,00 Nu: € 209,00 and that is great.

    But on some there’s nothing?
    https://www.globalfurniture-elst.nl/nieuw/product/ola-armstoel-tuinstoel-stoel-scab-design/

    How do I get all the Sale items to display like the first product, using your code?

    1. Hello Sanders, thanks for your comment and feedback! The only thing that comes to my mind is: do variations have the same price?

      1. Hi Rodolfo. I have problem with product variations with the same price. Price on the product page doesn’t display. Have you any idea how can i resolve this?

        1. Hey Simon, I tested my snippet with a variable product where variations have all the same price and it works perfectly – very weird 🙂 Do you have more information I could use to troubleshoot?

      2. Hi Rodolfo, sorry for my late reply! But I’m not receiving the notification mails from your website. (checked my spam and everything) I do receive the newsletter.

        To answer your question:
        The variations all have a different price.

        To target all simple products that are on sale as well would it be sufficient to change this: get_variation_price to: get_price ?

  73. Hello, I’m using your code to do this modification but something is not working correctly when I change language.
    Works fine on main language but on secondary language, appears as ” From: 30.00€ 0.00€ “. The line-through tag is not there, just so you know that is appears with a line through the text.
    If I remove your code it works fine, shows as ” 30.00€–46.00€ “…
    I was debugging it and this part is where it goes wrong:

    $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( 'from %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    
    echo '<pre>' . var_export($price, true) . '</pre>';
    

    This echo outputs the following:

    array (
    0 => false,
    1 => false,
    )

    It should output ” 0 => 40 ” and ” 1 => 46 ” like the main language… can you help me figure out how could I make it work?

    Thanks!

    1. Hey Rafael thanks for your comment 🙂 I’m not entirely sure what you mean here, but anyway if you’re looking to translate the “From”, I have this part here:

      ( 'from %1$s', 'woocommerce' )
      

      This should allow you to translate the ‘from %1$s’ into your own language with the translation plugin you’re using (WPML?).

      Let me know

      1. Hey Rodolfo, thanks for this amazign snippet!

        I am triing to translate the string from, but in WPML it does not show up…

        Do you have any hints why could that be?

        Thanks in advance!

        Greetings
        Marius

        1. In order to make a string translatable you have to wrap it in a __() function: https://codex.wordpress.org/I18n_for_WordPress_Developers#Translatable_strings – hope this helps 🙂

  74. Hi Rodolfo,

    I have exactly this code below in my function.php, and it still doesnt work, am i doing something wrong?

    
    	"OswadMarket",
    	'theme_slug'	=&gt;	'oswadmarket'
    ));
    $theme-&gt;init();
    
    /**
     * Slightly Modified Options Framework
     */
    require_once ('admin/index.php');
    
    add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    function wc_wc20_variation_price_format( $price, $product ) {
    // Main Price
    $prices = array( $product-&gt;get_variation_price( 'min', true ), $product-&gt;get_variation_price( 'max', true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    // Sale Price
    $prices = array( $product-&gt;get_variation_regular_price( 'min', true ), $product-&gt;get_variation_regular_price( 'max', true ) );
    sort( $prices );
    $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    if ( $price !== $saleprice ) {
    $price = '<del>' . $saleprice . '</del> ' . $price . '';
    }
    return $price;
    }
    
    ?&gt;
    
    
    1. I have used it plenty of times with other websites by the way and it works there!

      1. Hey Marge thanks for your comment! I don’t know, that is not my code so I’m afraid I’m not entirely sure. Also, it could be the theme you’re using is already using those filters 🙂

        1. it is your code, I got the part above from you a couple of years ago…

          1. I see – it must be a previous version then 🙂 Try to disable all plugins but WooCommerce and switch theme temporarily. Does the code work in this case?

  75. Great code thanks a lot. The code is working fine except the language part is still a thing. The word “From” is not translated into the native language of our website . Native language is dutch so we would like to have “Vanaf” instead. Changing the text “From” to ” Vanaf” didn’t help.

    I tried also an earlier tip you gave “you may want to change the code slightly and use “_e” instead of “sprintf” or “echo”… something like this: “_e( ‘From ‘ );”. Hope this helps you figure it out”

    But I do not know how exactly it suppose to be coded due to my lack of code knowledge. Please can you help to exactly code and how to replace the sprintf part by _e or echo?

    Thanks a lot for your help.

    1. Hey Richard, thanks for your comment! If you replace both “From:” with “Vanaf:” it must work, maybe clear your cache after you update the snippet 🙂 Let me know!

  76. Amazing, Thanks so much for such code 🙂

    1. Thank you so much Ardavan 🙂

  77. Rodolfo,

    Thanks so much for your guides, they’ve been very helpful as there’s almost no information out there about customizing woocommerce! I’m a C/C++/C#/Java/Python style programmer just getting into web development, so this kind of information is vital for me.

    Anyways, I used the filters you showed here and wrote my own function (ended up being basically the same) to remove the price range only on the product page. The problem is that when variable products show up in the “Related Products” section of the product page, it also removes the price range there, because it’s technically still on the product page. Any ideas on how I can get the price range to show up in the “Related Products” section but not at the top of the product page still? There isn’t any obvious conditional logic for this, something like is_the_product_being_displayed, but that’s not a wc_product() function. If I knew how to get the product ID of the product on the page, I could check if it matches that ID and only disable it then, but I’m not sure how to get the product ID of the product on the current page.

    Any help is greatly appreciated!

    1. Hey Justin, thanks so much for your comment and feedback! I have to say I never offer free support here on the blog but this particular topic came across already from another fan. It was really bugging me until… NOW! In fact, I found the solution, see if this helps: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/#1-are-you-working-on-the-woocommerce-single-product-page and check the section “PHP: do something on the related products only“. Let me know 🙂

      1. Perfect solution, just added ” && $woocommerce_loop[‘name’] != ‘related'” next to isProduct() so this solved my problem. Much appreciated!

  78. Hi Rodolfo!
    Thanks for your post. I remove price range on product page on my website 🙂
    I have another problem because I want remove maximum price on category (and other listings pages) and add before minimum price word “From”.
    How can I do this? Have you any idea?

    1. Hello Simon, excellent, glad this helped (if you want to share your final snippet in the comments to help others, feel free to do so). In regard to the category/shop/loop pages, you just need to use a different “conditional tag”.

      Take a look at this guide and you will find out the one you need to use: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/

  79. Hi. I am trying to disable price range in the single product page only and I entered the following code. It does not work. Can you please tell me where I am going wrong? I would really appreciate it if you gave me the correct code.

     function bbloomer_variation_price_format( $price, $product ) {
     if ( is_product() ) {
    add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_remove_variation_price', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'bbloomer_remove_variation_price', 10, 2 );
     
    function bbloomer_remove_variation_price( $price ) {
    $price = '';
    return $price;
    }
     }
    } 
    
    1. Hey Fahad, thanks so much for your comment!

      Unfortunately this is custom development work and I cannot provide you with a solution this time. If you would like to get a quote for the fix, feel free to go here to get in touch.

      Thanks for your understanding!

      ~R

  80. Hi there,

    I have two price variables for pre-order products on my site, one for a deposit and one for the full price and just want the full price to show on the site.

    How I can I achieve this?

    1. Hey Stuart, thanks for your comment! I’m actually not sure as this is completely dependent on your deposit add-on. You’ll need to study the plugin code and see how it “generates” prices – sorry but I can’t help this time 🙂

  81. Thank you Rodolfo!! Works like a charm 🙂

    Amazing that you would post this to help all of us less knowledgeable to use.

    Great work. If you ever come to Australia I owe you a beer!

    1. Cheers Mike, thanks a lot. Looking forward to that beer 🙂

  82. Hi….Thank for your post…

    how can i show only minimum price for Entirely, Everywhere?

    1. Hey Mubarak, thanks for your comment! This snippet already does what you’re asking (as long as I understood your question). Maybe send me a screenshot to explain your issue in more detail. Thanks 🙂

  83. Thanks for sharing this saved me a great amount of time and your function worked well for me!

    1. Excellent, thank you so much for your feedback!

  84. Amazin, thanks so much!!!

    1. You’re very welcome José! Thanks for your feedback 🙂

  85. Thank you so much for an amazing tutorial! This really worked and helped me out!

    2 Questions:

    1. How do i get the From to display on regular prices? Currently it just displays the price.

    2. How can i add a class to the From to add colour to it etc

    1. Sorry and one last one, how do i also show the undiscounted price next to the lowest price?

      1. Hey Stef, thanks for your comments!

        1) That’s strange – it should show on both regular and sale prices. Send me a screenshot maybe 🙂
        2) You can try using ‘From: %1$s’ instead of ‘From: %1$s’ (untested), and then targeting “range_from” via CSS
        3) I’m afraid I don’t understand that – can you make me an example?

        Cheers!

        R

        1. Hi Rodolfo

          Thanks for the reply.

          1. Have sent screenshot via email.

          2. Cool will try that.

          3. Have sent a screenshot of what i meant.

          Thank you again for being so cool!

          1. Thank you Stef, I’ll see what I can do 🙂

  86. Hi thanks for this but I can’t seem to get it working. I’ve posted the snippet under PHP Snippet #1: Disable WooCommerce Variable Product Price Range $$$-$$$ into my child theme’s function.php file but it screws up the entire page. The code appears at the top above the menu then nothing else on the page is rendered.

    Your insight would be greatly appreciated!

    1. Hey Rene, thanks a million for your feedback! Uhm, I find it difficult to troubleshoot without having access to your code. Try:

      1) using the latest WooCommerce
      2) disabling all plugins but WooCommerce
      3) switching theme temporarily

      Does the snippet work in this case?

  87. Thank you very much.

    Can you please help me out on removing the range from the product page only but keep the from price in the categories page?

    Thank you in advance for your reply.

    1. Sara, thanks for your comment! This is pretty simple – just use WooCommerce conditional logic for the product page:

      
      function bbloomer_variation_price_format( $price, $product ) {
      
      if ( is_product() ) {
      
      // original function here
      
      }
      
      }
      
      

      Let me know if this works 🙂

  88. How can I remove the “from: price” on my product page for subscriptions??

    1. Hello Melinda, and thanks for your comment 🙂 I’m afraid I don’t own the/a subscription plugin so I can’t help this time! Have you tried asking the plugin developers?

  89. P.S. I don´t know php.. I cant understand how to use your example:

    use “_e” instead of “sprintf” or “echo”… something like this: “_e( ‘From ‘ );”

    Hope you could help me.

    Thanks a lot and best regards

    1. Hey Viviana, thanks for your comment! You can simply substitute the two ‘From: %1$s’ with ‘Desde: %1$s’.

      Hope this helps!

  90. Hello Rodolfo, thanks for your help!!! I need to change the “from” word to spanish: Desde. How could I do it? Thanks a lot and best regards
    Viviana

  91. Hi Rodolfo

    Man, i am happy to have found your website.

    I have a WordPress (Latest release) website using WooCommerce (Latest release).
    With WooCommerce i use the following 2 plugins

    1. Dynamic Pricing – https://www.woothemes.com/products/dynamic-pricing/
    2. Min/Max Quantities -https://www.woothemes.com/products/minmax-quantities/

    I have set a variable product to receive a fixed price discount i.e.

    min 20: unit price £9.90 (23%)
    min 40: unit price £9.40 (27%)
    min 60: unit price £8.90 (31%)
    https://oi67.tinypic.com/102qi49.jpg

    and set min/max quantities to group of 20
    https://oi63.tinypic.com/2q0onqc.jpg

    Now in the front end the price shows

    “From £9.90”

    and i wish it show the lowest price i.e.

    “From £8.90”

    https://oi64.tinypic.com/255pger.jpg

    I wish this to be displayed on my shop overview page and single product page.

    Is there a tutorial of yours which would be able to help me achieve this?

    I am looking through your videos and posts but not finding any on this (still learning)

    Thanks a mill for your site and support.

    cheers

    1. Hey Conrad, thanks for your comment! I’m afraid this particular snippet might not be compatible with other plugins that affect the pricing display, such as Dynamic Pricing. I don’t own the plugin so I can’t give you an exact answer, but the snippet should send you in the right direction.

      You should investigate how the plugin changes the price display by looking at the code, and possibly the solution won’t be much different from this one. Sorry if I can’t be of further help here 🙂

  92. Hi Rodolfo,
    Do you know if this code can be modified to do the same thing with grouped products?

    1. Hey Alan, if I remember well someone was asking the same in a previous comment! The code would look very similar, so you should study the code in the class-wc-product-grouped.php file (WooCommerce > Includes). Grouped products will need to use this filter: woocommerce_grouped_price_html. Hope this sends you in the right direction 🙂

  93. Hi Rodolfo, thanks for the code. I am a coding idiot myself whose experience is encompassed by about 3hrs of C++ my entire life.

    I used it on my webpage and found that even when there wasn’t a sale on the item, variable products will still display a strikethrough on the original price.
    e.g
    $25 $25.

    Found that it was because of the $price !== $saleprice condition.

    Added an else {$price == $price} to fix it.

    1. Hey Atticus thanks for your comment! I’m afraid I can’t replicate this error – I just tested it on my own dev site and it works perfectly if the variation has no sale price defined.

      Maybe this is a plugin/theme conflict?

      1. Possibly! But don’t see any harm completing the if else pair(:

        1. Ok, no problem at all 🙂

  94. Hi thanks for this code I’ve used it a few times so far. However now I have to display the discount a variable price gives. I want to show the %discount a person would get if they buy more. I’m assuming it is following the same hook for variable pricing.

    1. Andrew, thanks for your message 🙂 Your request is a little out of specs for this particular blog – however I just published a snippet that is similar to what you’re asking (at least in regard to the way it calculates the “savings”): https://businessbloomer.com/woocommerce-display-total-discount-savings-cart/. Let me know if that helps 🙂

  95. Hi, thanks for an informative board.

    I was able to remove the range, but we just want to show the minimum price. Not ‘From: xx.xx.

    Can you help?

    I would need to know exactly what to add or replace from code below. Or, remove entire chunk and place in something else.

    Thanks

    Jon

    1. Jon, thanks for your comment! Here’s the correct snippet for you:

      
      add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_variation_price_format_only_min', 10, 2 );
      
      add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_only_min', 10, 2 );
      
      function bbloomer_variation_price_format_only_min( $price, $product ) {
      
      // Main Price
      $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
      $price = wc_price( $prices[0] );
      
      // Sale Price
      $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
      sort( $prices );
      $saleprice = wc_price( $prices[0] );
      
      if ( $price !== $saleprice ) {
      $price = '<del>' . $saleprice . '</del> ' . $price . '';
      }
      return $price;
      }
      
      

      Let me know 🙂

      1. That did it!
        Thanks so much. A big help.
        If there is anything I can do for you, please let me know.
        I build sites in WP. Most are small biz sites and not ecomm, but as you can see, that can be done, too.
        Thanks again!
        JP

        1. You’re very welcome Jon! Hope to have you at my next WooCommerce online class at the end of the month – please stay in touch 🙂 Have a great day!

  96. Hello.

    I’ve tried putting your code into my child themes functions.php, but nothing is changing. I’ve tried both your codes, but none of them works.

    1. Hey Rasmus, thanks for your feedback! I just tried this snippet on WP 4.5.2 and WC 2.5.5 and it works perfectly 🙂 There must be something wrong with your child theme (do other functions work?), with a PHP error (check WP_DEBUG error logs) or a conflicting plugin (disable all plugins but WooCommerce and see if it works). Hope this helps 🙂

  97. I pasted in my functions.php and the price is completely gone. I cannot see any price at all. Neither other variables are working. can you help me with this? Thanks.

    1. Hello Jahir, thanks for your comment! I just tested the snippet on WC 2.5.5 and it works perfectly. Can you try disable all your plugins (excluded WooCommerce) and see if it works? In this case, there is some other plugin that conflicting with my snippet 🙂

  98. Thankyou so much for helping us .I read you all codes, It helped me.

    1. Thank you so much for your feedback Reetendra! 🙂

  99. Hmm……using 2nd code. Not working at all for me. Does nothing. Cleared cache. Still price range shows. Is this still compatible with latest versions of wp and wc?

    1. Hey Rob, thanks for your message 🙂 Yes, I just tested it with WC 2.5.5 and it works. This is the proof on the single product page for a variable product: https://screencast.com/t/bfYWSgky. Maybe check if you have other plugins affecting the price and disable them temporarily 🙂 Let me know!

      1. I am trying the 2nd code but its not working either.
        My theme does not have a function.php but custom-function.php
        Will it matters?

        1. Yes, this snippets need to go to your functions.php and won’t work in other files 🙂 Also, it is highly recommended to create a child theme, in which you can place all your custom coding (hence why I recommend to put snippets in your child theme functions.php).

          If you don’t want to use a child theme for whatever reason, you can install the “Code Snippets” free WordPress plugin and add the snippet in there.

          Hope this helps 🙂

          1. thanks for replying …
            I tried the Code snippets plugin … but its not working either

            1. Gotcha 🙂 Try switching theme and disabling all plugins but WooCommerce. If it works, then there is a problem with either theme or one of the plugins 🙂

  100. Thanks works well. I used snippet #2.

    1. Awesome Anthony, thanks for your feedback! 🙂

  101. You made my day! Thanks a lot for sharing! I was looking forward to show the maximum price only, so I tweaked a little bit snippet 2, localized the message and voila! Working in WP 4.4.2 and WC 5.5.5.
    Here is the code (it have the comments with credit on my site)

     add_filter( 'woocommerce_variable_sale_price_html', 'bbloomer_variation_price_format', 10, 2 );
     
    add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format', 10, 2 );
     
    function bbloomer_variation_price_format( $price, $product ) {
     
    // Main Price
    $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
    $price = $prices[0] !== $prices[1] ? sprintf( __( 'Máximo: %1$s', 'woocommerce' ), wc_price( $prices[1] ) ) : wc_price( $prices[1] );
     
    // Sale Price
    $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
    sort( $prices );
    $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'Máximo: %1$s', 'woocommerce' ), wc_price( $prices[1] ) ) : wc_price( $prices[1] );
     
    if ( $price !== $saleprice ) {
    $price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
    }
    return $price;
    1. I mean, worked in WC 2.5.5

    2. Glad to hear this Eduardo 🙂 Thanks for your feedback!

    3. I used this variation… and worked like a charm with the latest WP and WooCommerce installs. Thanks!!

      1. Thanks for your feedback Jamfris 🙂

  102. Hey! It worked fine in an older Woocommerce i tried, but not in 2.5.2.

    Any suggestions? Thanks 🙂

    1. Sorry – Just re-saved all variations and it worked.

      1. Awesome 🙂 I think Woo 2.5 was a big update. Thanks for your comment!

    1. Hey Alex thanks for your comment! This is strange, it should work everywhere. Do you have cache plugins enabled? And if you customized my snippet, can you post it here so I can take a look? Thank you!

      1. Well we do have redis object cache on the server + nginx php-fpm. But I work in admin mode plus cleared all server cache when testing in inkognito mode in chrome.

        No changes where made to your snippet. We’ll try again in staging with fever plugins activated.

        1. Cool, keep me posted! Try disabling all plugins but WooCommerce and switch theme on the Dev site to see if it still gives you error. ~R

          1. Found out that this snippet is currently not working together with
            WooCommerce Dynamic Pricing

            even if no pricing rules are active.

            https://www.woothemes.com/products/dynamic-pricing/

            1. Alex, thanks for your feedback! Correct, this snippet is only compatible with WooCommerce plugin as long as I’m aware. Third party plugins or themes might not work together – in that case you’ll need a custom fix to make sure they don’t override each other.

              If you find a version that works together with Dynamic Pricing, I’ll be happy to share it here – keep in touch!

  103. Hi,
    thanks for the nice snippet, it works great.
    But price isn’t showing up anymore at products that have variations (like different colors) but the same price.
    Is there a way I can fix that?
    I have the latest versions of my theme and WC.
    Jan

    1. Thanks for your comment Jan! I just checked on a test website and if variations have the same price, price should correctly show on top without the “From: “. Can you send me a screenshot please? Thank you 🙂

      1. Hi, I found the solution! After inserting the code into the functions.php, I re-saved all variations within the products that gave me the issue. And that solved the problem.
        Thanks for the code!

        1. Awesome! Thanks Jan for reporting back to the community 🙂

  104. Hey There, Thanks for this amazing snippet. I have a quick question.

    Within my theme there is a space between the currency symbol and the price itself. How do I remove this space?

    For example currently its displaying like “£ 4.95” and I would like it to show “£4.95”

    1. Thanks for your comment Tom! You should be able to change the spacing within WooCommerce Settings -> General -> Currency Position. Let me know 🙂

  105. Just want to say a quick thankyou for this snippet. Worked perfectly and saved me a lot of time.

    1. Thank you Samantha! 🙂

  106. Hi, how do I show both regular and sales price for variation product in woocommerce

    1. Habyb thanks for your comment 🙂 Have you tried using Snippet #2?

  107. This is so awesome… Thank you Rodolfo, Sir.. this saved my day. I also need one more help from you, If you see the screenshot attached the variation price in case if One of the variation is Discounted the prices show twice, this is so confusing. Link https://i64.tinypic.com/dmxvf9.png
    I would be so great ful for your help. Thank you so much.

    1. Thank you Subrodey 🙂 The price show twice everytime, is that correct? And which one do you want to delete, the top or the bottom one? Let me know. R

      1. Thank you for the reply, I would want to disable the bottom one as for all other products the rices show above. However in the variation discount product the coronet price change happens below. So ideally the bottom price should show above. if you know what i mean.

        1. I know what you mean 🙂 I’m afraid this is custom work and I cannot provide a solution right now – I’ll put it on my to-write list! Thank you 🙂

          1. Ah..thats sad. But thanks anyway. Just so that you know, I have looked into multiple forums and have not found any solution to this 🙁

            1. So, the “bottom” price for a variable price is generated by a php file called variable.php. This triggers the price to show via JQuery, once a variation is selected. This is why is below the variations and not above 🙂

              To complete the task, you should:

              1) remove the price on top of the variable products only (but it will show nothing!)
              2) override the add-to-cart/variable.php template in your child theme (but all you can do is putting the price above the select box and not really at the top of the page)

              This is quite complicated, this is why nobody has written a blog about this 🙂 Hope this helps you! ~R

          2. Hi, I am still waiting for you to tell me how to hide the below price and show only one price instead.

  108. My functions.php have no ?> in the end.
    I put the snnipet 2 after the last line. But I received the error Fatal error: Call to undefined function add_filter()
    Do you have thougs?

    1. forget it! I trying to edit functions.php in core. But i have edit functions.php of my theme and works! Nice!!!!!!

      1. Ahaha awesome Marcio 🙂

  109. Hello, i have put this code for showing anly the maximunm price :

    // Show MAX price instead
    add_filter(‘woocommerce_variable_price_html’, ‘custom_variation_price’, 10, 2);
    function custom_variation_price( $price, $product ) {
    $price = woocommerce_price($product->max_variation_price);
    return $price;
    }

    and it works excellent. But when i have a sale product the prices look all wrong with price ranges.

    Thank you

    1. Hey George thanks for your feedback 🙂 Have you tried using snippet 2 instead? That changes sale prices as well.

  110. Hi,

    Thank you for this article. I’ve added snippet 2, to functions.php. And it works!

    On the saleproducts, now it shows: “from €149,- FROM: €119,-” ,

    How can I remove the 2 ‘from’s?

    1. Hey Geza, thanks for your comment! Can you show me a screenshot or give me a URL please? Thank you! ~R

      1. just replace it in your snippet (with anything you want to have theire) 😉

  111. Hi Rodolfo,
    First of all thank you for your help and patient!
    Second, I have few questions I will glad if you can help me please.
    I’m selling products in bulkes of 50 pices (some even in 25 pices) when I’m adding the price of each variation (50,100,150 etc..) it displyed the price of 50 pices price to the 500 pices (the max amount) , my qoustion is if I want to show on the display the price of 1 piece price , min -max , and not 50 pices price to 500 pices price?
    (For example: 1 piece cost 1 usd when I buying 500 pices but it cost 2.4 usd if I’m buying 50 pices , in variation price of each I’m putting 120 usd for the 50 and 500 usd for the 500 pices , therefore in the display it showed 120-500 but I want it to show 1-2.4 .
    Is it possible?
    I would appreciate your help!

    1. Ilan, thanks so much for your feedback! Yes, this is possible – but unfortunately this is custom work and I cannot provide this solution on the blog right now. If you would like to get a quote, feel free to go here. Thank you! R

  112. Hey… is it possible to just change the price so that it shows the new variations price instead of using from or having the price range?

    1. Thanks for your comment Mike! Have you already tried selecting a default variation?

  113. Hi,
    kinda got a little issue. Since I’m running a mutlilingual store it would be great to hide the “from” in front of the price. So that it just shows the lowest price.

    Could you maybe help me with that, please?

    Cheers

    1. No problem 🙂 What snippet are you using, #1 or #2? R

  114. This was really helpful, solved my Woocommerce problem, and future proof it modifying my child theme, thanks Rodolfo.

    1. You’re welcome Rocko! Thanks for your feedback 🙂

  115. olá, estou com um problema na visualização dos produtos com variação.
    Seguinte:
    1º PROBLEMA: ao cadastrar um produto com variação e apenas 01 preço ele aparece na frente do preço: De: R$98,91.
    2º PROBLEMA: mesma situação de cima porém neste sim tem 2 preços e ele aparece assim: De: R$100,00 de R$ 85,00 (no caso deveria ser ex. de 100 por 85).

    1. Marco – sorry, can you write this in English please?

      1. Rough translation via Google.

        hello , I have a problem in the display of products with variations .
        next:
        1 PROBLEM : to register a product with variation and only 01 price he appears in front of Price : From: R $ 98.91 .
        2. PROBLEM : same situation as above but this does have 2 prices and it looks like this: From: R $ 100.00 to R $ 85.00 (in the case should be ex 100 for 85 . ) .

        1. Hi 🙂 Yes, the message is not very clear unfortunately. Could you send me some screenshots to show the problem graphically? Thank you. R

  116. Hi! We sell Chinese tea in variations 10g, 25g, 50g, 100g, 250g. But the standard amount is 50g. Is there any way to display this default price for 50g?

    1. Ivan, thanks for your message. Have you tried selecting “50g” as the default variation?

  117. Hi Rodolfo, thank you for the code. But if I want to include tax behind the price, where should I past the “echo woocommerce_price($product->get_price_including_tax());” code?

    1. Peter, thanks for your comment. Take a look at this previous reply: https://businessbloomer.com/disable-variable-product-price-range-woocommerce/#comment-6270. Hope it helps

      1. Thank you again Rodolfo, but may I ask if you have a quick way to add tax behind the price of the “Snippet 2”-code?

        How much does a beer cost where you live? I will donate you.

        1. Snippet 2 should already format with tax, doesn’t it? If not, you have to edit this part: wc_price( $prices[0] ). PayPal link is at the bottom of this blog post 🙂 Thank you!

          1. Hi Rodolfo, what Have I to edit en $prices to include tax?. Thanks a lot

        2. Hi, well, In my case Tax is the same for all products(16%) so I did this, If someone have a best idea…

          function wc_wc20_variation_price_format( $price, $product ) {
          // Main Price
          $prices = array( ($product->get_variation_price( ‘min’, true ))*( 1.16 ), $product->get_variation_price( ‘max’, true ) );
          $price = $prices[0] !== $prices[1] ? sprintf( __( ‘Desde: %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

          // Sale Price
          $prices = array( ($product->get_variation_regular_price( ‘min’, true ))*(1.16), $product->get_variation_regular_price( ‘max’, true ) );
          sort( $prices );
          $saleprice = $prices[0] !== $prices[1] ? sprintf( __( ‘Desde: %1$s’, ‘woocommerce’ ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

          if ( $price !== $saleprice ) {
          $price = ‘‘ . $saleprice . ‘ ‘ . $price . ”;
          }

  118. Hey Rodolfo, If i have variations that are all the same price (e.g colour variations) using code it still says “From $3.95” in this exception is there any easy way for the From to disapear. On variations with different prices the “From” options works well.

    1. Ignore that one Rodolfo, I used the second lot of code and it worked a charm 🙂 Really stocked with the improvement to my site https://eventfull.co.nz/product/water-bubbles-gel-beads/ & https://eventfull.co.nz/product/sky-lanterns/ behave just how I want them. Can i shout you a coffee/beer!

      1. Excellent! Good to know 🙂 Yes, coffees and beers are always welcome 🙂

  119. Hi, there are a solution, that i can hide the range price only in the product page and not in the catalog page?

    1. Elias, thanks for your feedback! Yes, this is possible of course. You can wrap the function contents inside a conditional check:

      function wc_wc20_variation_price_format() {
      if (is_product()) {
      // existing content here
      }
      }

  120. I am trying to achieve this in woocommerce subscriptions plugin..not getting need quick help.

    In the woocommerce product i am selling product with software monthly and yearly subscriptions..I want to show the base price as 200$ default and variation monthly has 20.99$ and yearly has 30.99$ which on selected will get added to base price and total price showed up…but I cant able to get this ..please anybody knows can you help me..thank you

    1. Thank you Rocket for your message – hope someone here can help 🙂

  121. Thanks so much for this, can you provide more info on what we need to change to get the minimum price to include Tax? (I see you responded to Roberto a few weeks ago but I’m not sure where the line of code you gave should go relative to the original snippet.

    Tnx

    1. Julianna, try using this and let me know: “echo woocommerce_price($product->get_price_including_tax());”

      1. Hi Rodolfo, thanks for the reply. I’m terrible with code.. Where do I paste that line in? Just at the bottom of the original snippet your provided?

        1. Julianna, where it says $price .= woocommerce_price($product->min_variation_price); change that to $price .= woocommerce_price($product->get_price_including_tax());

  122. Isn’t the simpler solution just:

    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’ );

    1. It may be 🙂 Can you show me a live example? Thanks so much!

  123. Brilliant! Works perfectly. Thanks a million.

  124. Hi Rodolfo,

    Is there a way to hide the price of one of my variable product options? The website I’m designing sells 3 items: postcards, greeting cards, and prints. The postcards are $1.00. The greeting cards are $4.00 The Prints are $75. It looks weird having the products say “$1.00 to $75.00” The website owner would like to have it say $1 to $4, and make no mention of the prints. But still have the prints as an option on the product page to purchase. Is there a way to accomplish this?

    Thank you,

    Kelsey

    1. Hey Kelsey, thanks for your comment. This is pretty advanced PHP and cannot really help here – however I have a quick question for you: why not saying “starting from $1” only? That could probably solve your issue. Let me know. R

  125. Hi,
    I’d like to remove regular price on sale product and to show only:
    From: the sale price

    How can I do that?

    Thanks

    1. Ciao Laura, in the second snippet, where it says:

      if ( $price !== $saleprice ) {
      $price = ‘‘ . $saleprice . ‘ ‘ . $price . ‘‘;
      }

      change that to:

      if ( $price !== $saleprice ) {
      $price = ‘‘ . $saleprice . ‘‘;
      }

      Let me know!

      1. thanks, but the second snippet it’s perfect for my variable product. I would like to use second snippet for simple product on sale too.

        1. Gotcha! This snippet works only with variable products. For simple products there might be different code to be implemented – having said that you can do this with CSS. If you give me the link to one of your non-variable product pages I’ll post the snippet here.

          1. Hi Rodolfo, I added prefix to simple product prices and so I resolved. Thank you 😉

  126. Looking for the following snippet:

    – Hide Variation Price Range ONLY on product page BUT ONLY when a variation option is selected; basically I’d like to keep the price range on the category view AND on the product view only when no variations are chosen

    1. Ryan, thanks for your feedback. Unfortunately this is custom work and cannot provide the snippet at the moment. Thanks for asking 🙂

  127. THANK YOU Rodolfo! very helpful

    1. You’re very welcome Nic!

  128. hi
    How can I view the minimum price with taxes included?

    1. Roberto, thanks for your question. Try using: “echo woocommerce_price($product->get_price_including_tax());” and let me know 🙂

  129. Just want to say thanks… You have no idea how quickly your ‘snippet’ got rid of a coding headache! 🙂

    1. Thank you so much Louise!

  130. Hi, if i’m using the composite product plug-in from Woo, how can i mimic what Snippet 2 does for these types of variable prices?

    Thanks 🙂

    1. Hey Chris thanks for your feedback 🙂 Unfortunately I don’t own that plugin so I can’t help here. Get in touch privately if you want to send me the files and I’ll take a look. Cheers!

  131. Hi,
    Can’t seem to find the answer no matter how much I search,
    trying to hide price, cart and quantity on a product for logged out users BUT KEEP the drop down variation.
    Need something simple like
    add_action( ‘PRODUCT VARIATION DROP DOWN’) but for the life of me cant find the correct code.
    Would appreciate any help as I’m at a loss.
    Regards,
    Ross

    1. Ross, thanks for your feedback! This is pretty advanced. I recommend to work on the woocommerce\templates\content-single-product.php and woocommerce\templates\single-product\add-t-cart\variable.php files and override them in your child theme. Not sure if this helps but I hope I put you in the right direction 🙂

  132. Hello!Help me please.
    How disable variation price range only in product page,not the catalog, only in product page?

    lesson 3 remove range everywhere,i need remove only in product page.
    Sorry for bad english…

    1. Hey Dmitry, thanks for your message. You can use a PHP if before the code that only applies the functionality if you’re on a product page. Such conditional tag in Woocommerce is called is_product(). For example:

      if (is_product()) {
      // do something
      }

  133. Thanks! Works perfectly. Donated to Paypal.

    1. Wow Robert – thank you SO MUCH!!!

  134. Hello Rodolfo and thanks for your article! We’re using Snippet 2 and it definitely helps. Do you have any recommendation for this scenario?:

    – Let’s say we have 2 product variations, Small and Large.
    – Using Snippet 2, the page now correctly displays only the Small price (“From $10,” for example, instead of “$10-$15”)
    – But what if we only have a Large item in stock? Is there a way to display some text only in that scenario? So the price might read “Large only, $15”

    I assume it has something to do with calling the slug of the variation attribute but I’m very new to Woo and still learning the ropes. Any help you have would be appreciated, thanks!

    1. Thanks for your feedback Justin. Take a look at a possible function like this:

      function check_if_variation_in_stock( $variation_id, $id ) {
          $variation = get_product( $variation_id );
          if ( ! $variation->is_in_stock() )
              // ---------
              // do something
      }
      
  135. great it works

    but what if i want to hide “FROM” word in this snippet

    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 .= ” . _x(‘From’, ‘min_price’, ‘woocommerce’) . ‘ ‘;
    $price .= woocommerce_price($product->min_variation_price);
    return $price;
    }

    1. Fatima, thanks for your feedback! To remove “from” simply use this code:

      add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
      function custom_variation_price( $price, $product ) {
      $price = ";
      $price .= woocommerce_price($product->min_variation_price);
      return $price;
      }
      

      Hope this helps 🙂

  136. Useful post! Thank you for sharing. I have a question: how to display only max price with variations product have sale prices ?

    1. Thanks for your question Nghia! To display max price try using $product->max_variation_price. Hope it helps 🙂

  137. Thank for this post!

    I have a question? How to show format as following

    Size M: $20
    Size L: $50

    Thank U!

    1. Toan, thanks for your question! Unfortunately this is pretty advanced and maybe I’ll use this in one of my next posts. Keep in touch 🙂

      1. Thank U. I resolve this problem

  138. I’m looking to just display the larger number. We’re offering a deposit option that makes the low-end. But we don’t want people to think that the lower price is the actual cost. If they pay the deposit, they still have to settle-up and pay the difference between the deposit amount and the full price. So we’re looking to only display the full price. Could the 1st snippet be modified to only display the highest price, and not “from” or anything like that?

    1. Tevya, thank you so much for your reply. To show the MAX price, simply use this:

      // Show MAX price instead
      add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
      function custom_variation_price( $price, $product ) {
      $price = woocommerce_price($product->max_variation_price);
      return $price;
      }
      

      Let me know 🙂

      1. Thanks for responding! However, that didn’t seem to work. Instead of just “$775” output, I got “$200–$775$775”. So the range is still there, with an extra Max price added right after, no space. HTML looks like this:

        `$200–$775$775`

        1. Tevya, sorry, there is an error in the code 🙂 Change the line “$price .= woocommerce_price($product->max_variation_price);” to “$price = woocommerce_price($product->max_variation_price);” (remove the dot)

          1. Rodolfo, thank you! That worked.

            1. Awesome Tevya, thank you 🙂

    2. So now it’s showing $1200 even though we changed the variation price to $1250. Any idea why that is?

  139. Hi, i used the 3 snippets above and no one works? why?

    1. Jair, thank you so much for your feedback! could you please describe what version of Woocommerce you use and also what template? Your theme developers might have customized the single product page heavily and changed a few hooks, so maybe this is why this doesn’t work. Let me know!

      1. Hi
        when i try to copy that to function. php there are

        Fatal error: Call to undefined function add_filter() in /customers/b/e/b/trykpol.dk/httpd.www/wp-includes/functions.php on line 13

        where i have to put it then or how?

        1. Anna thank you for your feedback! Can you copy/paste the first 14 lines of your functions.php – I will see if I can help 🙂

  140. I installed a plugin in order to show prices by role. I have different products with many variations and each one has differents prices according to the rol. Woocommerce show a range price of the variations, but i want to show in product page just the role price assigned.

    1. Jair, thank you for your message! Indeed what you’re asking is quite advanced and really depends on the plugin you’re using. They probably have a way to display the price through a PHP function and that is the function that you should use in this snippet instead of the one I provided. Contact me if you need further help. Thanks!

  141. Thank you for your post.

    I implemented it on our site (Example: https://drnes.com/product/phantom-3-professional/)

    Quick question: do you know how I would adjust the top blue price to update like the bottom blue price does when a different variable is selected from the dropdown?

    For example: on that product page I linked to, both the top and bottom prices start as “$1,259.00”. When I select “Extended Package (+$100)” from the dropdown menu, the bottom price updates to “$1,359.00” while the top price remains as “$1,259.00”.

    How can I change it so that the top price also updates to “$1,359.00” when the variation is selected?

    Thank you

    1. Thank you Brady for your feedback! And perfect timing 🙂 I’m developing a plugin that does just that, so I will let you know when this is ready. R

      1. Hi Rudolfo!

        Thank you for your sharing. It works great but I guess it doesn’t update when another variable product selected from the drop down, can you confirm this?

        Anything I can do to get the price updated when a variation selected?

        Cheers!

        1. Ozgur, thanks a million for your comment! So, this in not meant to update when you select a different variable – it shows the min price no matter what 🙂 Does this make sense?

  142. Hi, thanks for sharing. It is working but showing the minimum price. how can i get price of default preselected variable instead ?

    thanks

    1. Thanks for your feedback Jitesh 🙂 Yes, what you’re asking it is possible but at the moment I have no time to publish this edit, it basically requires you loop through the variations and identify the default price. I’ll keep you posted!

  143. Hi Rodolfo, I have a similar though not identical issue. My website has a variable product set up for selling the product singly, as a square foot, and as a box, as well as a sample. How could I set things up so that the square foot price is always the price that is shown, no matter the other prices? Usually the sample is the lowest cost, followed by a single piece, then square foot. But sometimes a single might be larger than a square foot, and so more expensive.

    I imagine that other than the code to insert into the .php file, it would be good to set up the product in some coordinated way.

    What’s my one-two punch strategy here?

    1. Hello Magda, thanks for your question! I suppose your request needs custom PHP. It is indeed possible to show – say – the “max price”, but you will need a developer to get that done unless you’re good at PHP.

      Hope this makes sense 🙂

  144. This snippet works great for a single variable product – however if I use the variable product as part of a product bundle (using the WooTheme extension “Product Bundles”) the price is still shown as $xx-$yy – any ideas on fixing this issue?

    Kind regards.

    1. Thanks for your comment Morten! Probably that plugin has a different output for products – I will need to take a look at its PHP code in order to help but I’m afraid I don’t own the plugin. If you want to send me the files at INFO at BUSINESSBLOOMER.COM I can take a look!

  145. A BIG thank you for supplying this code. You have been really helpful and saved me a lot time.

    Grazie molto.

    1. You’re so welcome Cynic! Thanks for the feedback 🙂

  146. Hi,

    Thanks for this awesome snippet!

    Is it possible to display “Incl. VAT” behind the prices?

    1. You’re welcome 🙂 What do you mean by “behind the prices”? Can you show an example?

    2. For instance: € 545,56 incl. VAT

  147. Works perfectly! I have removed the ‘From’ option and it fits perfectly. Thank you very much.

    1. Awesome, thank you Toni!

  148. Works perfectly. Thanks for the code Rodolfo.

  149. Hi, I used the code and it works fine (thanks for sharing). But my shop is in 3 languages. How can I change the word FROM to AB in German and DESDE in Spanish? I tried with Codestyling localization but it does not change. Any idea? Thank you in advance.

    1. Torsten, thanks for your feedback! In regard to translation, you may want to change the code slightly and use “_e” instead of “sprintf” or “echo”… something like this: “_e( ‘From ‘ );”. Hope this helps you figure it out

  150. Thank you that worked!

  151. hi where in functions.php do i add this? top? bottom or middle, sorry im new at this!

    1. Hey Marge, thanks for your comment! You can add this at the bottom of the functions.php, right before this sign (if you have any): ?>

  152. Hi, I want to translate “From:” into Dutch “Vanaf” from the second code. But when i do that my shop pages are completely white.. Can you help me?

    1. Chris, it should work even if you change that word. You probably forgot a comma and that is breaking the theme. Do you want to paste the code you used?

  153. i am relatively new to WP and have had a problem for days now, i am building a site with lots of price variations, but the annoying thing is i have managed to show only the lowest price on the shop pages, but on the product pages the lowest price still shows, and this is before the customer has chosen their variations, i would like to remove the lowest price on the product pages as it is very confusing for customers, i only want them to see a price once they have made their selection, i had a developer work on this but they are not available, here is the code i used to remove the price variations on the shop pages:

    add_filter(‘woocommerce_variable_sale_price_html’,’nyasro_price_fix’,10,2); add_filter(‘woocommerce_variable_price_html’,’nyasro_price_fix’,10,2); function nyasro_price_fix( $price, $woo ) { $price = ”.get_woocommerce_currency_symbol().$woo->get_variation_price().”; return $price;

    https://postimg.org/image/4nl6tw673/
    https://s3.postimg.org/qlhnnol7n/hair_2.png

    hopefully the images are clear on what i need done, and hopefully someone can give me a code that works.

    many thanks

  154. Wow just saved my biggest hedache! I’ll be looking for you on fiverr to help me in the future for sure !

    1. Excellent! Cheers Kiwami 🙂

  155. OMG Rodolfo. You’re a true hero! It works perfect.

    Is it possible to show the first add-on option on product page?

    1. Awesome 🙂 I’m sure the add-on plugin lets you select a default add-on?

      1. Unfortunately not. Not even if you set a required field 🙁

        1. Fair enough – you will either need to talk to the plugin developers or hire a developer at this stage 🙂

          1. Ok. That was also only if possible.
            Thank you so much for your help again. You have really helped. Now the webshop is starting to take place.

            If you’re ever in Copenhagen drop me an e-mail and I will get you a big bag of coffee from the shop 🙂 🙂 🙂

            Have the most wonderful day.
            Ciao Mads

            1. Mads, thanks a lot for that. Looking forward to my next trip to Copenhagen then! Take it easy

  156. Hi Rodolfo,
    I’m new into WP. Where/which functions.php is it?
    Br,
    Mads

    1. Hey Mads, thanks for your comment! You can find functions.php in your template folder. If you use FTP, you will find it easily there. If you use the WordPress dashboard, go to Appearance / Editor and functions.php will be in the list on the right. Hope this helps!

      1. Thanks! Got it! And now it shows perfect. Even translated to Danish 😉
        Can I ask you another question? Should I post it another place?

        1. Awesome Mads! Thank you 🙂 Feel free to post it here and if necessary I’ll create another post.

          1. Great!
            It’s regarding the plug-in “WooCommerce Product Add-ons”.
            Hope you know it.

            The plug-in Works fine and the looks are great. I really like the “select-button-option, but… 😉

            I’d like it to treat the product more as a variable than add-on.
            My problem is that I can’t figure out how to change the code, so it just takes the ‘add-on price’ alone, and not add it to the regular Price. Does that make any sense? 🙂

            If I just don’t set any regular Price, the product shows as ‘Free’!

            1. Mads, what about just hiding the “Free” label?

              1. Yeah! That could Work. Even though I will not get the Price shown in the productpage. Perhaps it could show first option?

                Thank you so much for helping me. I’ve been searching the web for days.

                1. Yes, that would make sense. Instead of “0” you could show something like “From XXX”. That’s a simple job.

                  To hide the “free” label use this:

                  
                  add_filter( 'woocommerce_variable_free_price_html',  'hide_free_price_label' );
                   
                  add_filter( 'woocommerce_free_price_html',           'hide_free_price_label' );
                   
                  add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price_label' );
                   
                  function hide_free_price_label( $price ) {
                     return '';
                  }
                  
                  
  157. Hi Rodolfo, many thank, this code is very helpful, but it not working when the products work with the woo-plug measures and dimension https://www.woothemes.com/products/measurement-price-calculator/

    can your check this please? i’m too stupid for this 😉
    i can set up a demoshop with the plug for you if you need.

    thx and greetz from germany!

    1. Thank you Reini for your comment! Yes, that plugin probably already hooks into “woocommerce_variable_price_html” so the above filter doesn’t do anything. I will need to take a look at the plugin code to give you a definite answer!

      1. wow, you are fast! thx 🙂

        1. Thank you! It’s my USP 🙂

  158. Thanks for the pointers! I found this (and what’s probably the source for the second code) while searching for a way to only display the price of whichever product I set as default. This isn’t quite it yet since it just shows the lowest price, default or not. (The OP in the forum I looked first had the same request, but this is the code he/she got.) But this’ll do for now. .

    1. Thanks Max, I guess by “lowest price” and “default price” you mean the “sale price” and “regular price” respectively? If yes, there is a way to show only the regular or only the sale price. Let me know what you found out!

      1. Thanks for the reply. No, I wnt to set one of the variables as that product’s default and show that price. I have books in different formats, including ebooks, paperbacks and hardcovers. The lowest price is usually the ebook price, but I’d prefer to show the paperback price in the catalogue.

        1. Max, I see, I understand now 🙂 Well, what you ask is a little bit more complicated. finding the min or max is very simple, but finding the default requires much more coding. For reference, I would recommend to check the function “get_variation_default_attributes()” on this page: https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-product-variable.php

          Hope this helps!

          1. I had a similar problem. I too, want the default price to be shown on the products display page. I checked out the function but it didnt and while I understood what I was reading, I still don’t know how to get the default price to show. It would mean a lot to some of us if there was an article somewhere on how to do this.
            Thanks for the information Rodolfo! 🙂

            1. Thanks for your feedback! I’ll see what I can do 🙂

  159. Thanks. What if I want to stick in replacement text that was not related to variations such as “From $9” I’m using a discounting plugin that’s not showing price in the product if that makes sense.

    1. Dan, thanks for your comment! I don’t entirely understand what you want to achieve. Maybe you can provide a screenshot or explain it a little bit better? thank you!

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *