public function applyFlatDiscount($amount, $couponId = null)
    {
        if ($amount > $this->subtotal) {
            throw new IncorrectDiscount('The discount amount cannot be more that subtotal of the cart');
        }

        $this->discount = round($amount, 2);
        $this->discountPercentage = 0;
        $this->couponId = $couponId;

        $cartData = $this->cartUpdates($isNewItem = false, $keepDiscount = true);

        event(new DiscountApplied($cartData));

        return $cartData;
    }
public function applyFlatDiscount($amount, $couponId = null)
    {
        if ($amount > $this->subtotal) {
            throw new IncorrectDiscount('The discount amount cannot be more that subtotal of the cart');
        }

        $this->discount = round($amount, 2);
        $this->discountPercentage = 0;
        $this->couponId = $couponId;

        $cartData = $this->cartUpdates($isNewItem = false, $keepDiscount = true);

        event(new DiscountApplied($cartData));

        return $cartData;
    }
public function applyFlatDiscount ( $ amount , $ couponId = null ) { if ( $ amount > $ this -> subtotal ) { throw new IncorrectDiscount ( 'The discount amount cannot be more that subtotal of the cart' ) ; } $ this -> discount = round ( $ amount , 2 ) ; $ this -> discountPercentage = 0 ; $ this -> couponId = $ couponId ; $ cartData = $ this -> cartUpdates ( $ isNewItem = false , $ keepDiscount = true ) ; event ( new DiscountApplied ( $ cartData ) ) ; return $ cartData ; }
Applies flat disount to the cart.

@param float Discount amount
@param int Coupon id
@return array
@throws IncorrectDiscount
Applies flat disount to the cart .