Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Renderer\Blocks

Product_Price::build_variable_product_priceprivateWC 1.0

Build price HTML for variable products. Uses the same logic as the editor: get_variation_price() methods.

Method of the class: Product_Price{}

No Hooks.

Returns

String.

Usage

// private - for code of main (parent) class only
$result = $this->build_variable_product_price( $product ): string;
$product(WC_Product_Variable) (required)
Variable product object.

Product_Price::build_variable_product_price() code WC 10.5.0

private function build_variable_product_price( \WC_Product_Variable $product ): string {
	$min_price = $product->get_variation_price( 'min', true );
	$max_price = $product->get_variation_price( 'max', true );

	return sprintf(
		'<span>%s — %s</span>',
		wc_price( (float) $min_price, array( 'in_span' => false ) ),
		wc_price( (float) $max_price, array( 'in_span' => false ) )
	);
}