Posted on

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

You may want to disable the variable product price range which usually looks like $100-$999. With this snippet you will be able to hide the highest price, plus add a “From: ” in front of the minimum price. All you need is pasting the following code in your child theme’s functions.php πŸ™‚

WooCommerce: Disable Variation Price Range @ Single Product Page
WooCommerce: Disable Variation Price Range @ Single Product Page

PHP Snippet #1 (Woo 3.1.0+): Disable WooCommerce Variable Product Price Range $$$-$$$ – print “From: $min_price” instead


/**
 * @snippet       Disable Variable Product Price Range
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/disable-variable-product-price-range-woocommerce/
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.3.4
 */

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

PHP Snippet #1 (Woo <3.1.0): Disable WooCommerce Variable Product Price Range $$$-$$$


/**
 * @snippet       Disable Variable Product Price Range
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @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;
}

PHP Snippet #3: Disable Variable Product Price Range on the WooCommerce Single Product Page Only (excluding Shop/Archives)

In this case, 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/

PHP Snippet #4: Remove WooCommerce Variable Price Range Entirely, Everywhere


/**
 * @snippet       Remove Variable Product Prices Everywhere
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @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_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;
}

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance πŸ™‚

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert, WordCamp speaker and Internet marketer, Rodolfo Melogli has worked as a WooCommerce freelancer since 2011. He helps entrepreneurs and developers overcome their WooCommerce nightmares πŸ™‚ Rodolfo is the organiser of WordCamp Dublin, the Dublin WooCommerce Meetup, the Dublin Ecommerce Meetup and the Dublin WordPress Meetup. He enjoys interacting with people, travelling and chasing tennis & soccer balls. Of course, he loves pizza too.

380 thoughts on “WooCommerce: Edit Variable Product Price Range $$$-$$$

  1. 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 πŸ™‚

  2. 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.

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

    1. I’m afraid not πŸ™‚

  4. 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 πŸ™‚

  5. Hi there,

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

    Thank

  6. 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

  7. 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

  8. 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/

  9. 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.

    3. Brilliant! Thanks Vishnu πŸ™‚

  10. 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

  11. 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.

    3. 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

  12. 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

  13. 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!

  14. 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 ?

    2. 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

  15. Works Perfectly! Thank you πŸ™‚

    1. Brilliant πŸ™‚

  16. 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 πŸ™‚

  17. 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.

    3. Can you try the latest/revised snippet please? Cheers πŸ™‚

  18. 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 πŸ™‚

  19. 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.

  20. 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

  21. 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        Watch tutorial @ https://businessbloomer.com/?p=19055
     * @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

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

    4. Tried Storefront and twentyseventeen neither worked.

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

    6. 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

    7. 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 πŸ™‚

  22. 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.

    3. Please paste your code as I have no idea without looking at it πŸ™‚

    4. /**
       * @snippet       Disable Variable Product Price Range
       * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
       * @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;
      } 
    5. 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.

  23. 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 πŸ™‚

  24. 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!

    2. Awesome stuff, thank you Sarrah!

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

    1. Thanks so much for your feedback Lewin!

  26. 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 πŸ™‚

  27. 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

    2. 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

  28. 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 πŸ™‚

    2. 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?

    3. More or less πŸ™‚ You can always try on a test website!

    4. 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?

    5. 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 πŸ™‚

    6. Thanks mate, look forward to reading it!

  29. 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?

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

    3. 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 πŸ™‚

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

  30. 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!

  31. 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() ) {

  32. 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?

    2. Version 3.0.1 – is that good news or bad news!? πŸ™‚

    3. 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!

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

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

    6. Sorry, i mean the hide all snippet

    7. 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

    8. 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 πŸ™‚

    9. <3 + :))

      Buona Pasqua

    10. Cheers! Same to you πŸ™‚

  33. 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)

    3. 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

    4. 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!

  34. 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/bloomer-armada/, and the $39 pack would definitely cover your request. Let me know and thanks a lot for your understanding!

    2. Are these scripts still compatible with version 4.7.3?

    3. Hey Walmir, thanks for your comment! They definitely should, so give it a go and let me know πŸ™‚

  35. 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!

    2. 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.

    3. 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 πŸ™‚

  36. 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 πŸ™‚

  37. 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?

    2. 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?

    3. 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?

    4. 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 ?

  38. 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

  39. 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!

    2. 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 πŸ™‚

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

    4. 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?

  40. 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!

  41. Amazing, Thanks so much for such code πŸ™‚

    1. Thank you so much Ardavan πŸ™‚

  42. 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 πŸ™‚

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

  43. 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/

  44. 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

  45. 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 πŸ™‚

  46. 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 πŸ™‚

  47. 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 πŸ™‚

  48. 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!

  49. Amazin, thanks so much!!!

    1. You’re very welcome JosΓ©! Thanks for your feedback πŸ™‚

  50. 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?

    2. 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

    3. 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!

    4. Thank you Stef, I’ll see what I can do πŸ™‚

  51. 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?

  52. 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 πŸ™‚

  53. 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?

  54. 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!

  55. 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

  56. 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%)
    http://oi67.tinypic.com/102qi49.jpg

    and set min/max quantities to group of 20
    http://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”

    http://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 πŸ™‚

  57. 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 πŸ™‚

  58. 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?

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

    3. Ok, no problem at all πŸ™‚

  59. 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”): http://businessbloomer.com/woocommerce-display-total-discount-savings-cart/. Let me know if that helps πŸ™‚

  60. 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 πŸ™‚

    2. 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

    3. 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!

  61. 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 πŸ™‚

  62. 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 πŸ™‚

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

    1. Thank you so much for your feedback Reetendra! πŸ™‚

  64. 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: http://screencast.com/t/bfYWSgky. Maybe check if you have other plugins affecting the price and disable them temporarily πŸ™‚ Let me know!

    2. 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?

    3. 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 πŸ™‚

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

    5. 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 πŸ™‚

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

    1. Awesome Anthony, thanks for your feedback! πŸ™‚

  66. 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!!

    4. Thanks for your feedback Jamfris πŸ™‚

  67. 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.

    2. 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!

    2. 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.

    3. 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

    4. 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/

    5. 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!

  68. 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 πŸ™‚

    2. 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!

    3. Awesome! Thanks Jan for reporting back to the community πŸ™‚

  69. 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 πŸ™‚

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

    1. Thank you Samantha! πŸ™‚

  71. 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?

  72. 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 http://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

    2. 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.

    3. 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 πŸ™‚

    4. 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 πŸ™

    5. 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

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

  73. 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!!!!!!

    2. Ahaha awesome Marcio πŸ™‚

  74. 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.

  75. 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

    2. just replace it in your snippet (with anything you want to have theire) πŸ˜‰

  76. 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

  77. 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?

  78. 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

  79. 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 πŸ™‚

  80. 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?

    2. 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 . ) .

    3. Hi πŸ™‚ Yes, the message is not very clear unfortunately. Could you send me some screenshots to show the problem graphically? Thank you. R

  81. 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?

  82. 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: http://businessbloomer.com/disable-variable-product-price-range-woocommerce/#comment-6270. Hope it helps

    2. 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.

    3. 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!

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

    5. 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 . ”;
      }

  83. 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 http://eventfull.co.nz/product/water-bubbles-gel-beads/ & http://eventfull.co.nz/product/sky-lanterns/ behave just how I want them. Can i shout you a coffee/beer!

    2. Excellent! Good to know πŸ™‚ Yes, coffees and beers are always welcome πŸ™‚

  84. 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
      }
      }

  85. 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 πŸ™‚

  86. 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());”

    2. 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?

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

  87. 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!

  88. Brilliant! Works perfectly. Thanks a million.

    1. Thank you so much Kara!

  89. 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

  90. 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!

    2. 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.

    3. 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.

    4. Hi Rodolfo, I added prefix to simple product prices and so I resolved. Thank you πŸ˜‰

  91. 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 πŸ™‚

  92. THANK YOU Rodolfo! very helpful

    1. You’re very welcome Nic!

  93. 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 πŸ™‚

  94. 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!

  95. 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!

  96. 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 πŸ™‚

  97. 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
      }

  98. Thanks! Works perfectly. Donated to Paypal.

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

  99. 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
      }
      
  100. 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 πŸ™‚

  101. 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 πŸ™‚

  102. 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 πŸ™‚

    2. Thank U. I resolve this problem

  103. 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 πŸ™‚

    2. 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`

    3. 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)

    4. Rodolfo, thank you! That worked.

    5. Awesome Tevya, thank you πŸ™‚

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

  104. 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!

    2. 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?

    3. 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 πŸ™‚

  105. 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!

  106. Thank you for your post.

    I implemented it on our site (Example: http://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

    2. 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!

    3. 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?

  107. 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!

  108. 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 πŸ™‚

  109. 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!

  110. 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 πŸ™‚

  111. 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

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

    1. Awesome, thank you Toni!

  113. Works perfectly. Thanks for the code Rodolfo.

  114. 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

  115. Thank you that worked!

  116. 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): ?>

  117. 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?

  118. 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;

    http://postimg.org/image/4nl6tw673/
    http://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

  119. 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 πŸ™‚

  120. 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?

    2. Unfortunately not. Not even if you set a required field πŸ™

    3. Fair enough – you will either need to talk to the plugin developers or hire a developer at this stage πŸ™‚

    4. 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

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

  121. 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!

    2. Thanks! Got it! And now it shows perfect. Even translated to Danish πŸ˜‰
      Can I ask you another question? Should I post it another place?

    3. Awesome Mads! Thank you πŸ™‚ Feel free to post it here and if necessary I’ll create another post.

    4. 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’!

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

    6. 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.

    7. 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 '';
      }
      
      
  122. Hi Rodolfo, many thank, this code is very helpful, but it not working when the products work with the woo-plug measures and dimension http://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!

    2. wow, you are fast! thx πŸ™‚

    3. Thank you! It’s my USP πŸ™‚

  123. 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!

    2. 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.

    3. 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!

    4. 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! πŸ™‚

    5. Thanks for your feedback! I’ll see what I can do πŸ™‚

  124. 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? Support? Leave your Comment Now!
If you're writing code, please wrap it between: [php] code_here [/php]

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