LukePOLO\LaraCart\Traits\CouponTrait::maxDiscount PHP Method

maxDiscount() public method

Returns either the max discount or the discount applied based on what is passed through.
public maxDiscount ( $maxDiscount, $discount, $throwErrors = true ) : mixed
$maxDiscount
$discount
$throwErrors
return mixed
    public function maxDiscount($maxDiscount, $discount, $throwErrors = true)
    {
        if ($maxDiscount == 0 || $maxDiscount > $discount) {
            return $discount;
        } else {
            if ($throwErrors) {
                throw new CouponException('This has a max discount of ' . \App::make(\LukePOLO\Laracart\LaraCart::SERVICE)->formatMoney($maxDiscount));
            } else {
                return $maxDiscount;
            }
        }
    }