Menu Close

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

default

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

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

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

WooCommerce: disable the variable product price range

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

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

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

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

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

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