Automattic\WooCommerce\StoreApi\Schemas\V1

CartShippingRateSchema::get_item_response()publicWC 1.0

Convert a shipping rate from WooCommerce into a valid response.

Method of the class: CartShippingRateSchema{}

No Hooks.

Return

Array.

Usage

$CartShippingRateSchema = new CartShippingRateSchema();
$CartShippingRateSchema->get_item_response( $package );
$package(array) (required)
Shipping package complete with rates from WooCommerce.

CartShippingRateSchema::get_item_response() code WC 8.9.0

public function get_item_response( $package ) {
	return [
		'package_id'     => $package['package_id'],
		'name'           => $package['package_name'],
		'destination'    => $this->prepare_package_destination_response( $package ),
		'items'          => $this->prepare_package_items_response( $package ),
		'shipping_rates' => $this->prepare_package_shipping_rates_response( $package ),
	];
}