@managesome/eposmatic-toolkit 0.2.297 → 0.2.299
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -982,6 +982,15 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
982
982
|
}
|
|
983
983
|
return Math.min(normalizedUnlockableClaims, getRemainingOfferUsesForCustomer(offerToCheck));
|
|
984
984
|
};
|
|
985
|
+
const isDiscountSlotOccupiedForOffer = (offerToCheck) => {
|
|
986
|
+
if (order_discount_details == null) {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
if (offerToCheck.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.VOUCHER) {
|
|
990
|
+
return Boolean(order_discount_details.voucher_discount_id);
|
|
991
|
+
}
|
|
992
|
+
return Boolean(order_discount_details.loyalty_discount_id);
|
|
993
|
+
};
|
|
985
994
|
for (let i = 0; i < offers.length; i++) {
|
|
986
995
|
const offer = offers[i];
|
|
987
996
|
const stats = {
|
|
@@ -1069,15 +1078,19 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1069
1078
|
}
|
|
1070
1079
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1071
1080
|
const isRedeemed = redeemedTimes > 0;
|
|
1072
|
-
|
|
1081
|
+
const discountSlotOccupied = isDiscountSlotOccupiedForOffer(offer);
|
|
1082
|
+
stats.claimable = !isRedeemed && !discountSlotOccupied;
|
|
1073
1083
|
stats.applicable_quantity = 1;
|
|
1074
1084
|
stats.redeemed_times = redeemedTimes;
|
|
1075
|
-
if (
|
|
1076
|
-
|
|
1077
|
-
|
|
1085
|
+
if (isRedeemed) {
|
|
1086
|
+
stats.message = 'This offer is redeemed ✅';
|
|
1087
|
+
}
|
|
1088
|
+
else if (discountSlotOccupied) {
|
|
1089
|
+
stats.message = 'You already have an offer applied to your order.';
|
|
1078
1090
|
}
|
|
1079
1091
|
else {
|
|
1080
|
-
|
|
1092
|
+
totalClaimableOffers += 1;
|
|
1093
|
+
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1081
1094
|
}
|
|
1082
1095
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1083
1096
|
}
|
|
@@ -1343,12 +1356,16 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1343
1356
|
}
|
|
1344
1357
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1345
1358
|
const isRedeemed = redeemedTimes > 0;
|
|
1359
|
+
const discountSlotOccupied = isDiscountSlotOccupiedForOffer(offer);
|
|
1346
1360
|
stats.redeemed_times = redeemedTimes;
|
|
1347
1361
|
stats.applicable_quantity = 1;
|
|
1348
|
-
stats.claimable = !isRedeemed;
|
|
1362
|
+
stats.claimable = !isRedeemed && !discountSlotOccupied;
|
|
1349
1363
|
if (isRedeemed) {
|
|
1350
1364
|
stats.message = 'This offer is redeemed ✅';
|
|
1351
1365
|
}
|
|
1366
|
+
else if (discountSlotOccupied) {
|
|
1367
|
+
stats.message = 'You already have an offer applied to your order.';
|
|
1368
|
+
}
|
|
1352
1369
|
else {
|
|
1353
1370
|
totalClaimableOffers += 1;
|
|
1354
1371
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
@@ -1598,12 +1615,16 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1598
1615
|
}
|
|
1599
1616
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1600
1617
|
const isRedeemed = redeemedTimes > 0;
|
|
1618
|
+
const discountSlotOccupied = isDiscountSlotOccupiedForOffer(offer);
|
|
1601
1619
|
stats.redeemed_times = redeemedTimes;
|
|
1602
1620
|
stats.applicable_quantity = 1;
|
|
1603
|
-
stats.claimable = !isRedeemed;
|
|
1621
|
+
stats.claimable = !isRedeemed && !discountSlotOccupied;
|
|
1604
1622
|
if (isRedeemed) {
|
|
1605
1623
|
stats.message = 'This offer is redeemed ✅';
|
|
1606
1624
|
}
|
|
1625
|
+
else if (discountSlotOccupied) {
|
|
1626
|
+
stats.message = 'You already have an offer applied to your order.';
|
|
1627
|
+
}
|
|
1607
1628
|
else {
|
|
1608
1629
|
totalClaimableOffers += 1;
|
|
1609
1630
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
@@ -1856,12 +1877,16 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1856
1877
|
}
|
|
1857
1878
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
1858
1879
|
const isRedeemed = redeemedTimes > 0;
|
|
1880
|
+
const discountSlotOccupied = isDiscountSlotOccupiedForOffer(offer);
|
|
1859
1881
|
stats.redeemed_times = redeemedTimes;
|
|
1860
1882
|
stats.applicable_quantity = 1;
|
|
1861
|
-
stats.claimable = !isRedeemed;
|
|
1883
|
+
stats.claimable = !isRedeemed && !discountSlotOccupied;
|
|
1862
1884
|
if (isRedeemed) {
|
|
1863
1885
|
stats.message = 'This offer is redeemed ✅';
|
|
1864
1886
|
}
|
|
1887
|
+
else if (discountSlotOccupied) {
|
|
1888
|
+
stats.message = 'You already have an offer applied to your order.';
|
|
1889
|
+
}
|
|
1865
1890
|
else {
|
|
1866
1891
|
totalClaimableOffers += 1;
|
|
1867
1892
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|