How to Hide Price that price range which appears on WooCommerce Variable Products

If you add a variable product to WooCommerce, you will notice the low and high price range of the variations will display. While this is ok, sometimes it can be a good idea to have it disabled.

Navigate to appearance and theme editor and select the functions.php file. Just copy and paste the code below to the bottom your themes functions.php file and save. If your using a child theme paste it into the bottom of your child themes functions.php file.

//Hide Price Range for WooCommerce Variable Products
add_filter( 'woocommerce_variable_sale_price_html',
'lw_variable_product_price', 10, 2 );
add_filter( 'woocommerce_variable_price_html',
'lw_variable_product_price', 10, 2 );

function lw_variable_product_price( $v_price, $v_product ) {

// Product Price
$prod_prices = array( $v_product->get_variation_price( 'min', true ),
$v_product->get_variation_price( 'max', true ) );
$prod_price = $prod_prices[0]!==$prod_prices[1] ? sprintf(__('From: %1$s', 'woocommerce'),
wc_price( $prod_prices[0] ) ) : wc_price( $prod_prices[0] );

// Regular Price
$regular_prices = array( $v_product->get_variation_regular_price( 'min', true ),
$v_product->get_variation_regular_price( 'max', true ) );
sort( $regular_prices );
$regular_price = $regular_prices[0]!==$regular_prices[1] ? sprintf(__('From: %1$s','woocommerce')
, wc_price( $regular_prices[0] ) ) : wc_price( $regular_prices[0] );

if ( $prod_price !== $regular_price ) {
$prod_price = ''.$regular_price.$v_product->get_price_suffix() . ' ' . $prod_price . $v_product->get_price_suffix() . '';
}
return $prod_price;
}
Scroll to Top