Hide max price for variable products in WooCommerce

add_filter( 'woocommerce_variable_sale_price_html', 'hide_variable_max_price', PHP_INT_MAX, 2 );
add_filter( 'woocommerce_variable_price_html',      'hide_variable_max_price', PHP_INT_MAX, 2 );
function hide_variable_max_price( $price, $_product ) {
	$min_price_regular = $_product->get_variation_regular_price( 'min', true );
	$min_price_sale    = $_product->get_variation_sale_price( 'min', true );
	return ( $min_price_sale == $min_price_regular ) ?
		wc_price( $min_price_regular ) :
		'<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins>';
}

5 Comments

  1. Howard Flint June 1, 2016 at 7:28 pm #

    WHERE do we paste this into the code? Be specific

    • Tom June 1, 2016 at 7:36 pm #

      Hi,

      You should put the code in your (child) theme’s functions.php file.

      Best regards,
      Tom

  2. Huỳnh Ngọc Duy June 30, 2016 at 4:22 am #

    @Tom: is it possible to show minimum price only?? and how??

    Thank you very much

    • Huỳnh Ngọc Duy June 30, 2016 at 4:23 am #

      Oh I’m sorry, Show maximum price only, not minimum price

      thanks

  3. Sean Bridge October 22, 2016 at 3:17 pm #

    How do I create a space between the sale price and regular price? I have no space.

Leave a Reply