From 2a1c79a8efad766030be19e243153cc7bc4b1e3e Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 6 Oct 2023 10:12:13 +0100 Subject: [PATCH] Support blank and null coupons (#1293) --- packages/core/src/Managers/DiscountManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/Managers/DiscountManager.php b/packages/core/src/Managers/DiscountManager.php index fc99415aa2..5744479eac 100644 --- a/packages/core/src/Managers/DiscountManager.php +++ b/packages/core/src/Managers/DiscountManager.php @@ -140,8 +140,8 @@ public function getDiscounts(Cart $cart = null): Collection ) )->when( $cart?->coupon_code, - fn ($query, $value) => $query->where('coupon', '=', $value)->orWhereNull('coupon'), - fn ($query, $value) => $query->whereNull('coupon') + fn ($query, $value) => $query->where('coupon', '=', $value)->orWhere(fn ($query) => $query->whereNull('coupon')->orWhere('coupon', '')), + fn ($query, $value) => $query->whereNull('coupon')->orWhere('coupon', '') )->orderBy('priority', 'desc') ->orderBy('id') ->get();