Automattic\WooCommerce\StoreApi\Schemas\V1
OrderFeeSchema::get_item_response
Convert a WooCommerce cart fee to an object suitable for the response.
Method of the class: OrderFeeSchema{}
No Hooks.
Returns
array.
Usage
$OrderFeeSchema = new OrderFeeSchema(); $OrderFeeSchema->get_item_response( $fee );
- $fee(WC_Order_Item_Fee) (required)
- Order fee object.
OrderFeeSchema::get_item_response() OrderFeeSchema::get item response code WC 11.2.2
public function get_item_response( $fee ) {
if ( ! $fee ) {
return [];
}
return [
'key' => $fee->get_id(),
'name' => $this->prepare_html_response( $fee->get_name() ),
'totals' => (object) $this->prepare_currency_response(
[
'total' => $this->prepare_money_response( $fee->get_total(), wc_get_price_decimals() ),
'total_tax' => $this->prepare_money_response( $fee->get_total_tax(), wc_get_price_decimals(), PHP_ROUND_HALF_DOWN ),
]
),
];
}