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

Product_Price::build_variable_product_price │ private │ WC 1.0

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

Метод класса: Product_Price{}

Хуков нет.

Возвращает

string.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->build_variable_product_price( $product ): string;
$product(WC_Product_Variable) (обязательный)
Variable product object.

Код Product_Price::build_variable_product_price() WC 11.2.2

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 ) )
	);
}