Disable Variable Product Price Range In WooCommerce

Quick Summary
- Replace WooCommerce's variable product price range with the lowest price and a Starting At prefix, for all products or a single product ID.
- When sale and regular prices differ, the regular price is struck through, and the prefix is dropped if all variations cost the same.
- Use only one of the two snippets, since both declare wc_varb_price_range and PHP stops with a fatal error on a duplicate function.
By default WooCommerce shows a variable product price range, such as $15 – $80. These snippets replace that range with the lowest price and a prefix, so the product shows Starting At: $15 instead. The first one applies to every variable product in your store, the second to a single product ID. To keep the range and print it in a custom product loop instead, see showing the variable price range with get_price_html().
Add the code to your child theme’s functions.php or a code snippets plugin. Use only one of the two: both declare a function named wc_varb_price_range, and PHP stops with a fatal error if the same function is declared twice.
Change the price range for all variable products
function wc_varb_price_range( $wcv_price, $product ) {
$prefix = sprintf('%s: ', __('Starting At', 'wcvp_range'));
$wcv_reg_min_price = $product->get_variation_regular_price( 'min', true );
$wcv_min_sale_price = $product->get_variation_sale_price( 'min', true );
$wcv_max_price = $product->get_variation_price( 'max', true );
$wcv_min_price = $product->get_variation_price( 'min', true );
$wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?
wc_price( $wcv_reg_min_price ) :
'<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>';
return ( $wcv_min_price == $wcv_max_price ) ?
$wcv_price :
sprintf('%s%s', $prefix, $wcv_price);
}
add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 );- The code attaches the function to two WooCommerce filters for variable product price HTML, and it returns its own HTML in place of the range.
- It reads the lowest regular price, the lowest sale price, and the lowest and highest active prices. The
trueargument returns the prices as the shop displays them, following your tax display settings. - If the lowest sale and regular prices match, it shows one price. Otherwise it shows the regular price struck through (
<del>) followed by the sale price. - When all variations cost the same, the code leaves the prefix out.
- Change
Starting Atto your own wording.wcvp_rangeis the text domain used for translation.
Change it for a single product only
This version wraps the same logic in a check for one product ID. Replace 218835 with your product’s ID, which appears when you hover over the product in the Products list.
//VARIABLE PRODUCT PRICE CHANGE
function wc_varb_price_range( $wcv_price, $product ) {
if( $product->get_id() == 218835 ) {
$prefix = sprintf('%s: ', __('Starting At', 'wcvp_range'));
$wcv_reg_min_price = $product->get_variation_regular_price( 'min', true );
$wcv_min_sale_price = $product->get_variation_sale_price( 'min', true );
$wcv_max_price = $product->get_variation_price( 'max', true );
$wcv_min_price = $product->get_variation_price( 'min', true );
$wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?
wc_price( $wcv_reg_min_price ) :
'<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>';
}
return ( $wcv_min_price == $wcv_max_price ) ?
$wcv_price :
sprintf('%s%s', $prefix, $wcv_price);
}
add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 );For every other variable product, the variables used in the return line are never set. The original price HTML still comes back, because two undefined values compare as equal, but PHP logs an undefined variable warning each time. If you see these warnings in your error log, return $wcv_price early when the ID doesn’t match.
If your variable products need their prices shown your own way across the store, see my WooCommerce development services.
Related articles
- showing the discount amount and percentage under the price: another way to change how sale prices appear
