Automattic\WooCommerce\StoreApi\Schemas\V1
OrderCouponSchema::get_item_response
Convert an order coupon to an object suitable for the response.
Метод класса: OrderCouponSchema{}
Хуков нет.
Возвращает
array.
Использование
$OrderCouponSchema = new OrderCouponSchema(); $OrderCouponSchema->get_item_response( $coupon );
- $coupon(WC_Order_Item_Coupon) (обязательный)
- Order coupon object.
Код OrderCouponSchema::get_item_response() OrderCouponSchema::get item response WC 11.2.2
public function get_item_response( $coupon ) {
$coupon_object = new \WC_Coupon( $coupon->get_code() );
return [
'code' => $coupon->get_code(),
'discount_type' => $coupon_object ? $coupon_object->get_discount_type() : '',
'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 ),
]
),
];
}