WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartCouponSchema::get_item_response() public WC 1.0

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

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

Хуков нет.

Возвращает

Массив.

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

$CartCouponSchema = new CartCouponSchema();
$CartCouponSchema->get_item_response( $coupon_code );
$coupon_code(строка) (обязательный)
Coupon code from the cart.

Код CartCouponSchema::get_item_response() WC 4.7.1

<?php
public function get_item_response( $coupon_code ) {
	$controller           = new CartController();
	$cart                 = $controller->get_cart_instance();
	$total_discounts      = $cart->get_coupon_discount_totals();
	$total_discount_taxes = $cart->get_coupon_discount_tax_totals();
	return [
		'code'   => $coupon_code,
		'totals' => (object) array_merge(
			$this->get_store_currency_response(),
			[
				'total_discount'     => $this->prepare_money_response( isset( $total_discounts[ $coupon_code ] ) ? $total_discounts[ $coupon_code ] : 0, wc_get_price_decimals() ),
				'total_discount_tax' => $this->prepare_money_response( isset( $total_discount_taxes[ $coupon_code ] ) ? $total_discount_taxes[ $coupon_code ] : 0, wc_get_price_decimals(), PHP_ROUND_HALF_DOWN ),
			]
		),
	];
}