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