public function totalDiscount($format = true, $withItemDiscounts = true)
    {
        $total = 0;

        if ($withItemDiscounts) {
            /** @var CartItem $item */
            foreach ((array) $this->cart->items as $item) {
                $total += floatval($item->getDiscount(false));
            }
        }

        foreach ($this->cart->coupons as $coupon) {
            if ($coupon->appliedToCart) {
                $total += $coupon->discount();
            }
        }

        if ($total < 0) {
            $total = $this->subTotal(false);
        }

        return $this->formatMoney($total, null, null, $format);
    }
public function totalDiscount($format = true, $withItemDiscounts = true)
    {
        $total = 0;

        if ($withItemDiscounts) {
            /** @var CartItem $item */
            foreach ((array) $this->cart->items as $item) {
                $total += floatval($item->getDiscount(false));
            }
        }

        foreach ($this->cart->coupons as $coupon) {
            if ($coupon->appliedToCart) {
                $total += $coupon->discount();
            }
        }

        if ($total < 0) {
            $total = $this->subTotal(false);
        }

        return $this->formatMoney($total, null, null, $format);
    }
public function totalDiscount ( $ format = true , $ withItemDiscounts = true ) { $ total = 0 ; if ( $ withItemDiscounts ) { /** @var CartItem $item */ foreach ( ( array ) $ this -> cart -> items as $ item ) { $ total += floatval ( $ item -> getDiscount ( false ) ) ; } } foreach ( $ this -> cart -> coupons as $ coupon ) { if ( $ coupon -> appliedToCart ) { $ total += $ coupon -> discount ( ) ; } } if ( $ total < 0 ) { $ total = $ this -> subTotal ( false ) ; } return $ this -> formatMoney ( $ total , null , null , $ format ) ; }
Gets the total amount discounted.

@param bool $format
@param bool $withItemDiscounts

@return string
Gets the total amount discounted .