-
Notifications
You must be signed in to change notification settings - Fork 462
Description
Lunar version: 1.0.0‑beta.24
Laravel Version: 11.45.1
PHP Version: 8.2.28
Database Driver & Version: MySQL 8
Expected Behaviour:
Coupon codes should be either case‑insensitive or explicitly enforced as uppercase. The validator should reject any code entered in lowercase at creation time, or automatically convert it to uppercase ( in admin panel ).
For example:
Admin tries to save code test10 → validation error “Only uppercase letters and numbers allowed.”
Or admin enters test10 and it’s auto‑uppercased to TEST10 on save.
Actual Behaviour
-
Lowercase coupon codes (e.g.,
test10) can be created and saved in the admin panel without any warning. -
When such a lowercase code (
test10) is applied programmatically using:$this->cart->update([ 'coupon_code' => 'test10', ]);
— it succeeds.
-
However, if you try to apply the same code with an uppercase letter (e.g.,
Test10):$this->cart->update([ 'coupon_code' => 'Test10', ]);
— it fails.
-
method
Discounts::validateCouponreturnstruefor both'test10'and'Test10'.
Steps To Reproduce:
-
Create a coupon code in the admin panel
Go to the admin panel and create a new discount with a lowercase code, e.g.,test10. Save it. -
Apply the coupon code programmatically (lowercase)
In your code, update the cart using:$this->cart->update([ 'coupon_code' => 'test10', ]);
The coupon is applied successfully.
-
Apply the coupon code programmatically (different capitalization)
Now, try updating the cart using:$this->cart->update([ 'coupon_code' => 'Test10', ]);
The operation fails—the coupon is not applied.
-
Validate the coupon code with both cases
Call the validation method for both variants:Discounts::validateCoupon('test10'); // returns true Discounts::validateCoupon('Test10'); // also returns true
Both validations succeed, even though only the lowercase variant works when applying the coupon.