Automattic\WooCommerce\StoreApi\Schemas\V1

CartFeeSchema::get_item_response()publicWC 1.0

Convert a WooCommerce cart fee to an object suitable for the response.

Method of the class: CartFeeSchema{}

No Hooks.

Return

Array.

Usage

$CartFeeSchema = new CartFeeSchema();
$CartFeeSchema->get_item_response( $fee );
$fee(array) (required)
Cart fee data.

CartFeeSchema::get_item_response() code WC 9.3.3

public function get_item_response( $fee ) {
	return [
		'key'    => $fee->id,
		'name'   => $this->prepare_html_response( $fee->name ),
		'totals' => (object) $this->prepare_currency_response(
			[
				'total'     => $this->prepare_money_response( $fee->total, wc_get_price_decimals() ),
				'total_tax' => $this->prepare_money_response( $fee->tax, wc_get_price_decimals(), PHP_ROUND_HALF_DOWN ),
			]
		),
	];
}