Automattic\WooCommerce\Blocks\StoreApi\Schemas
CartItemSchema::prepare_product_price_response() protected WC 1.0
Get an array of pricing data.
{} Это метод класса: CartItemSchema{}
Хуков нет.
Возвращает
Массив
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->prepare_product_price_response( \WC_Product $product, $tax_display_mode );
- \WC_Product $product (обязательный)
- -
- $tax_display_mode(строка)
- If returned prices are incl or excl of tax.
Код CartItemSchema::prepare_product_price_response() CartItemSchema::prepare product price response WC 5.2.2
protected function prepare_product_price_response( \WC_Product $product, $tax_display_mode = '' ) {
$tax_display_mode = $this->get_tax_display_mode( $tax_display_mode );
$price_function = $this->get_price_function_from_tax_display_mode( $tax_display_mode );
$prices = parent::prepare_product_price_response( $product, $tax_display_mode );
// Add raw prices (prices with greater precision).
$prices['raw_prices'] = [
'precision' => wc_get_rounding_precision(),
'price' => $this->prepare_money_response( $price_function( $product ), wc_get_rounding_precision() ),
'regular_price' => $this->prepare_money_response( $price_function( $product, [ 'price' => $product->get_regular_price() ] ), wc_get_rounding_precision() ),
'sale_price' => $this->prepare_money_response( $price_function( $product, [ 'price' => $product->get_sale_price() ] ), wc_get_rounding_precision() ),
];
return $prices;
}