WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartShippingRateSchema::prepare_package_items_response() protected WC 1.0

Gets items from a package and creates an array of strings containing product names and quantities.

{} It's a method of the class: CartShippingRateSchema{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_package_items_response( $package );
$package(array) (required)
Shipping package complete with rates from WooCommerce.

Code of CartShippingRateSchema::prepare_package_items_response() WC 5.8.0

protected function prepare_package_items_response( $package ) {
	$items = array();
	foreach ( $package['contents'] as $item_id => $values ) {
		$items[] = [
			'key'      => $item_id,
			'name'     => $values['data']->get_name(),
			'quantity' => $values['quantity'],
		];
	}
	return $items;
}