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

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartShippingRateSchema::get_item_response() public WC 1.0

Convert a shipping rate from WooCommerce into a valid response.

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

Хуки из метода
Возвращает

Массив.

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

$CartShippingRateSchema = new CartShippingRateSchema();
$CartShippingRateSchema->get_item_response( $package );
$package(массив) (обязательный)
Shipping package complete with rates from WooCommerce.

Код CartShippingRateSchema::get_item_response() WC 4.7.1

<?php
public function get_item_response( $package ) {
	// Add product names and quantities.
	$items = array();
	foreach ( $package['contents'] as $item_id => $values ) {
		$items[] = [
			'key'      => $item_id,
			'name'     => $values['data']->get_name(),
			'quantity' => $values['quantity'],
		];
	}

	// Generate package name.
	$package_number       = absint( $package['package_id'] ) + 1;
	$package_display_name = apply_filters(
		'woocommerce_shipping_package_name',
		$package_number > 1 ?
			sprintf(
				/* translators: %d: shipping package number */
				_x( 'Shipping %d', 'shipping packages', 'woocommerce' ),
				$package_number
			) :
			_x( 'Shipping', 'shipping packages', 'woocommerce' ),
		$package['package_id'],
		$package
	);

	return [
		'package_id'     => $package['package_id'],
		'name'           => $package_display_name,
		'destination'    => (object) $this->prepare_html_response(
			[
				'address_1' => $package['destination']['address_1'],
				'address_2' => $package['destination']['address_2'],
				'city'      => $package['destination']['city'],
				'state'     => $package['destination']['state'],
				'postcode'  => $package['destination']['postcode'],
				'country'   => $package['destination']['country'],
			]
		),
		'items'          => $items,
		'shipping_rates' => $this->prepare_rates_response( $package ),
	];
}