WC_Cart::get_coupon_discount_amount
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 Cart::get coupon discount amount WC 10.4.2
public function get_coupon_discount_amount( $code, $ex_tax = true ) {
$totals = $this->get_coupon_discount_totals();
$discount_amount = 0;
foreach ( $totals as $key => $value ) {
if ( wc_is_same_coupon( $key, $code ) ) {
$discount_amount = $value;
break;
}
}
if ( ! $ex_tax ) {
$discount_amount += $this->get_coupon_discount_tax_amount( $code );
}
return wc_cart_round_discount( $discount_amount, wc_get_price_decimals() );
}