Automattic\WooCommerce\StoreApi\Schemas\V1

OrderCouponSchema::get_item_response()publicWC 1.0

Convert an order coupon to an object suitable for the response.

{} Это метод класса: OrderCouponSchema{}

Хуков нет.

Возвращает

Массив.

Использование

$OrderCouponSchema = new OrderCouponSchema();
$OrderCouponSchema->get_item_response( $coupon );
$coupon(\WC_Order_Item_Coupon) (обязательный)
Order coupon array.

Код OrderCouponSchema::get_item_response() WC 7.1.0

public function get_item_response( \WC_Order_Item_Coupon $coupon ) {
	return [
		'code'   => $coupon->get_code(),
		'totals' => (object) $this->prepare_currency_response(
			[
				'total_discount'     => $this->prepare_money_response( $coupon->get_discount(), wc_get_price_decimals() ),
				'total_discount_tax' => $this->prepare_money_response( $coupon->get_discount_tax(), wc_get_price_decimals(), PHP_ROUND_HALF_DOWN ),
			]
		),
	];
}