WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartShippingRateSchema::get_rate_response() protected WC 1.0

Response for a single rate.

{} 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_response( $rate, $selected_rate );
$rate(WC_Shipping_Rate) (required)
Rate object.
$selected_rate(string)
Selected rate.
Default: ''

Code of CartShippingRateSchema::get_rate_response() WC 5.8.0

protected function get_rate_response( $rate, $selected_rate = '' ) {
	return $this->prepare_currency_response(
		[
			'rate_id'       => $this->get_rate_prop( $rate, 'id' ),
			'name'          => $this->prepare_html_response( $this->get_rate_prop( $rate, 'label' ) ),
			'description'   => $this->prepare_html_response( $this->get_rate_prop( $rate, 'description' ) ),
			'delivery_time' => $this->prepare_html_response( $this->get_rate_prop( $rate, 'delivery_time' ) ),
			'price'         => $this->prepare_money_response( $this->get_rate_prop( $rate, 'cost' ), wc_get_price_decimals() ),
			'taxes'         => $this->prepare_money_response( array_sum( $this->get_rate_prop( $rate, 'taxes' ) ), wc_get_price_decimals() ),
			'instance_id'   => $this->get_rate_prop( $rate, 'instance_id' ),
			'method_id'     => $this->get_rate_prop( $rate, 'method_id' ),
			'meta_data'     => $this->get_rate_meta_data( $rate ),
			'selected'      => $selected_rate === $this->get_rate_prop( $rate, 'id' ),
		]
	);
}