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

Product_Price::build_price_from_scratchprivateWC 1.0

Build price HTML completely from scratch based on product type.

Method of the class: Product_Price{}

No Hooks.

Returns

String.

Usage

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

Product_Price::build_price_from_scratch() code WC 10.5.0

private function build_price_from_scratch( \WC_Product $product ): string {
	$product_type = $product->get_type();

	switch ( $product_type ) {
		case 'simple':
		case 'external':
			return $this->build_simple_product_price( $product );

		case 'variable':
			// When the product does not have a correct type, the default will be used.
			if ( $product instanceof \WC_Product_Variable ) {
				return $this->build_variable_product_price( $product );
			}
			return $this->build_simple_product_price( $product );

		case 'grouped':
			// When the product does not have a correct type, the default will be used.
			if ( $product instanceof \WC_Product_Grouped ) {
				return $this->build_grouped_product_price( $product );
			}
			return $this->build_simple_product_price( $product );

		default:
			return $this->build_simple_product_price( $product );
	}
}