bug
This commit is contained in:
@@ -58,7 +58,7 @@ export class CartCalculationService {
|
||||
const coupon = await this.getCouponRestrictionsOrClear(cart);
|
||||
if (!cart.coupon || !coupon) return 0;
|
||||
|
||||
const hasCategoryRestriction = (coupon.foodCategories?.length ?? 0) > 0;
|
||||
const hasCategoryRestriction = (coupon.productCategories?.length ?? 0) > 0;
|
||||
const hasFoodRestriction = (coupon.products?.length ?? 0) > 0;
|
||||
|
||||
let eligibleItemsTotal = subTotal;
|
||||
@@ -75,7 +75,7 @@ export class CartCalculationService {
|
||||
if (!product) continue;
|
||||
|
||||
const matchesCategory =
|
||||
hasCategoryRestriction && product.category && (coupon.foodCategories ?? []).includes(product.category.id);
|
||||
hasCategoryRestriction && product.category && (coupon.productCategories ?? []).includes(product.category.id);
|
||||
const matchesFood = hasFoodRestriction && (coupon.products ?? []).includes(product.id);
|
||||
|
||||
if (matchesCategory || matchesFood) {
|
||||
@@ -189,7 +189,7 @@ export class CartCalculationService {
|
||||
isActive?: boolean;
|
||||
startDate?: Date;
|
||||
endDate?: Date;
|
||||
foodCategories?: string[];
|
||||
productCategories?: string[];
|
||||
products?: string[];
|
||||
} | null> {
|
||||
if (!cart.coupon) return null;
|
||||
@@ -214,7 +214,7 @@ export class CartCalculationService {
|
||||
isActive: c.isActive,
|
||||
startDate: c.startDate,
|
||||
endDate: c.endDate,
|
||||
foodCategories: c.foodCategories,
|
||||
productCategories: c.productCategories,
|
||||
products: c.products,
|
||||
};
|
||||
} catch {
|
||||
|
||||
@@ -221,7 +221,7 @@ export class CartService {
|
||||
await this.validationService.assertCouponUsageLimit(userId, (coupon as any).id, coupon.maxUsesPerUser);
|
||||
await this.validationService.assertCouponMatchesCartIfRestricted(
|
||||
cart,
|
||||
coupon.foodCategories,
|
||||
coupon.productCategories,
|
||||
coupon.products,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user