WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartItemSchema::get_item_response() public WC 1.0

Convert a WooCommerce cart item to an object suitable for the response.

{} Это метод класса: CartItemSchema{}

Хуков нет.

Возвращает

Массив.

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

$CartItemSchema = new CartItemSchema();
$CartItemSchema->get_item_response( $cart_item );
$cart_item(массив) (обязательный)
Cart item array.

Код CartItemSchema::get_item_response() WC 4.7.1

<?php
public function get_item_response( $cart_item ) {
	$product = $cart_item['data'];

	return [
		'key'                  => $cart_item['key'],
		'id'                   => $product->get_id(),
		'quantity'             => wc_stock_amount( $cart_item['quantity'] ),
		'quantity_limit'       => $this->get_product_quantity_limit( $product ),
		'name'                 => $this->prepare_html_response( $product->get_title() ),
		'short_description'    => $this->prepare_html_response( wc_format_content( $product->get_short_description() ) ),
		'description'          => $this->prepare_html_response( wc_format_content( $product->get_description() ) ),
		'sku'                  => $this->prepare_html_response( $product->get_sku() ),
		'low_stock_remaining'  => $this->get_low_stock_remaining( $product ),
		'backorders_allowed'   => (bool) $product->backorders_allowed(),
		'show_backorder_badge' => (bool) $product->backorders_require_notification() && $product->is_on_backorder( $cart_item['quantity'] ),
		'sold_individually'    => $product->is_sold_individually(),
		'permalink'            => $product->get_permalink(),
		'images'               => $this->get_images( $product ),
		'variation'            => $this->format_variation_data( $cart_item['variation'], $product ),
		'prices'               => (object) $this->prepare_product_price_response( $product, get_option( 'woocommerce_tax_display_cart' ) ),
		'totals'               => (object) array_merge(
			$this->get_store_currency_response(),
			[
				'line_subtotal'     => $this->prepare_money_response( $cart_item['line_subtotal'], wc_get_price_decimals() ),
				'line_subtotal_tax' => $this->prepare_money_response( $cart_item['line_subtotal_tax'], wc_get_price_decimals() ),
				'line_total'        => $this->prepare_money_response( $cart_item['line_total'], wc_get_price_decimals() ),
				'line_total_tax'    => $this->prepare_money_response( $cart_item['line_tax'], wc_get_price_decimals() ),
			]
		),
	];
}