WC_Cart::get_coupon_discount_amount()publicWC 1.0

Get the discount amount for a used coupon.

Метод класса: WC_Cart{}

Хуков нет.

Возвращает

float. discount amount

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

$WC_Cart = new WC_Cart();
$WC_Cart->get_coupon_discount_amount( $code, $ex_tax );
$code(строка) (обязательный)
coupon code.
$ex_tax(true|false)
inc or ex tax.
По умолчанию: true

Код WC_Cart::get_coupon_discount_amount() WC 9.4.2

public function get_coupon_discount_amount( $code, $ex_tax = true ) {
	$totals          = $this->get_coupon_discount_totals();
	$discount_amount = isset( $totals[ $code ] ) ? $totals[ $code ] : 0;

	if ( ! $ex_tax ) {
		$discount_amount += $this->get_coupon_discount_tax_amount( $code );
	}

	return wc_cart_round_discount( $discount_amount, wc_get_price_decimals() );
}