WordPress at Your Fingertips
function is not described

WC_Product_Variable::get_price_html() public WC 1.0

Returns the price in html format.

Note: Variable prices do not show suffixes like other product types. This is due to some things like tax classes being set at variation level which could differ from the parent price. The only way to show accurate prices would be to load the variation and get it's price, which adds extra overhead and still has edge cases where the values would be inaccurate.

Additionally, ranges of prices no longer show 'striked out' sale prices due to the strings being very long and unclear/confusing. A single range is shown instead.

{} It's a method of the class: WC_Product_Variable{}

Return

String.

Usage

$WC_Product_Variable = new WC_Product_Variable();
$WC_Product_Variable->get_price_html( $price );
$price(string)
Price (default: '').
Default: ''

Code of WC_Product_Variable::get_price_html() WC 5.8.0

public function get_price_html( $price = '' ) {
	$prices = $this->get_variation_prices( true );

	if ( empty( $prices['price'] ) ) {
		$price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
	} else {
		$min_price     = current( $prices['price'] );
		$max_price     = end( $prices['price'] );
		$min_reg_price = current( $prices['regular_price'] );
		$max_reg_price = end( $prices['regular_price'] );

		if ( $min_price !== $max_price ) {
			$price = wc_format_price_range( $min_price, $max_price );
		} elseif ( $this->is_on_sale() && $min_reg_price === $max_reg_price ) {
			$price = wc_format_sale_price( wc_price( $max_reg_price ), wc_price( $min_price ) );
		} else {
			$price = wc_price( $min_price );
		}

		$price = apply_filters( 'woocommerce_variable_price_html', $price . $this->get_price_suffix(), $this );
	}

	return apply_filters( 'woocommerce_get_price_html', $price, $this );
}