WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartShippingRateSchema::get_rate_meta_data() protected WC 1.0

Converts rate meta data into a suitable response object.

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

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_rate_meta_data( $rate );
$rate(WC_Shipping_Rate) (required)
Rate object.

Code of CartShippingRateSchema::get_rate_meta_data() WC 5.7.1

protected function get_rate_meta_data( $rate ) {
	$meta_data = $rate->get_meta_data();

	return array_reduce(
		array_keys( $meta_data ),
		function( $return, $key ) use ( $meta_data ) {
			$return[] = [
				'key'   => $key,
				'value' => $meta_data[ $key ],
			];
			return $return;
		},
		[]
	);
}