WC_Cart::get_coupon_discount_amount( string $code, bool $ex_tax = true )
Get the discount amount for a used coupon.
Description Description
Parameters Parameters
- $code
-
(Required) coupon code.
- $ex_tax
-
(Optional) inc or ex tax.
Default value: true
Return Return
(float) discount amount
Source Source
File: includes/class-wc-cart.php
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() );
}