@managesome/eposmatic-toolkit 0.2.299 → 0.2.301
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.
|
@@ -87,7 +87,7 @@ interface IGetOffersWithStats {
|
|
|
87
87
|
}
|
|
88
88
|
export declare function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOfferRedemptionCounts, redeemed_offers, platform, currency_symbol, currentItemsPrice, totalDiscountApplied, categories, order_discount_details, }: IGetOffersWithStats): {
|
|
89
89
|
offersWithStats: IOfferWithStats[];
|
|
90
|
-
totalClaimableOffers:
|
|
90
|
+
totalClaimableOffers: string[];
|
|
91
91
|
unlockedOffersApplicableTimes: Record<string, number>;
|
|
92
92
|
offersWithStatsHashKey: string;
|
|
93
93
|
unlockedOffersApplicableTimesHashKey: string;
|
|
@@ -821,10 +821,10 @@ function getRewardPreviewHashKey(rewardPreview) {
|
|
|
821
821
|
// The same rule applies to getUnlockedOffersApplicableTimesHashKey and getRewardPreviewHashKey.
|
|
822
822
|
function getOffersWithStatsHashKey(offersWithStats, totalClaimableOffers) {
|
|
823
823
|
if (offersWithStats.length === 0) {
|
|
824
|
-
return `offers:v1:empty:${totalClaimableOffers}`;
|
|
824
|
+
return `offers:v1:empty:${totalClaimableOffers.length}`;
|
|
825
825
|
}
|
|
826
826
|
const sortedOffers = [...offersWithStats].sort((a, b) => a.offer._id.localeCompare(b.offer._id));
|
|
827
|
-
let result = `offers:v1:${totalClaimableOffers}|`;
|
|
827
|
+
let result = `offers:v1:${totalClaimableOffers.length}|`;
|
|
828
828
|
for (let i = 0; i < sortedOffers.length; i++) {
|
|
829
829
|
const { offer, stats } = sortedOffers[i];
|
|
830
830
|
const eligibleItemIds = [...stats.eligible_item_ids].sort().join(',');
|
|
@@ -841,7 +841,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
841
841
|
const orderDiscount = order_discount_details?.total_discount ?? 0;
|
|
842
842
|
const itemsDiscount = totalDiscount - orderDiscount;
|
|
843
843
|
const unlockedOffersApplicableTimes = {};
|
|
844
|
-
let totalClaimableOffers =
|
|
844
|
+
let totalClaimableOffers = [];
|
|
845
845
|
let totalLoyaltyPointsOfCustomer = null;
|
|
846
846
|
const nowTs = Date.now();
|
|
847
847
|
const { voucherCodes: spendableVoucherCodesByCode } = calculateCustomerSpendableVoucherCodes({
|
|
@@ -1089,7 +1089,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1089
1089
|
stats.message = 'You already have an offer applied to your order.';
|
|
1090
1090
|
}
|
|
1091
1091
|
else {
|
|
1092
|
-
totalClaimableOffers
|
|
1092
|
+
totalClaimableOffers.push(offer._id);
|
|
1093
1093
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1094
1094
|
}
|
|
1095
1095
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1118,7 +1118,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1118
1118
|
stats.redeemed_times = redeemedTimes;
|
|
1119
1119
|
stats.applicable_quantity = applicableQuantity * maxRedeemableClaims;
|
|
1120
1120
|
if (isClaimable) {
|
|
1121
|
-
totalClaimableOffers
|
|
1121
|
+
totalClaimableOffers.push(offer._id);
|
|
1122
1122
|
stats.claimable = true;
|
|
1123
1123
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1124
1124
|
}
|
|
@@ -1150,7 +1150,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1150
1150
|
}
|
|
1151
1151
|
else {
|
|
1152
1152
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1153
|
-
totalClaimableOffers
|
|
1153
|
+
totalClaimableOffers.push(offer._id);
|
|
1154
1154
|
}
|
|
1155
1155
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1156
1156
|
}
|
|
@@ -1185,7 +1185,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1185
1185
|
else {
|
|
1186
1186
|
stats.claimable = true;
|
|
1187
1187
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1188
|
-
totalClaimableOffers
|
|
1188
|
+
totalClaimableOffers.push(offer._id);
|
|
1189
1189
|
}
|
|
1190
1190
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1191
1191
|
}
|
|
@@ -1219,7 +1219,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1219
1219
|
}
|
|
1220
1220
|
else {
|
|
1221
1221
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1222
|
-
totalClaimableOffers
|
|
1222
|
+
totalClaimableOffers.push(offer._id);
|
|
1223
1223
|
}
|
|
1224
1224
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1225
1225
|
}
|
|
@@ -1254,7 +1254,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1254
1254
|
else {
|
|
1255
1255
|
stats.claimable = true;
|
|
1256
1256
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1257
|
-
totalClaimableOffers
|
|
1257
|
+
totalClaimableOffers.push(offer._id);
|
|
1258
1258
|
}
|
|
1259
1259
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
1260
1260
|
}
|
|
@@ -1271,7 +1271,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1271
1271
|
stats.redeemed_times = redeemedTimes;
|
|
1272
1272
|
stats.applicable_quantity = applicableQuantity;
|
|
1273
1273
|
if (isClaimable) {
|
|
1274
|
-
totalClaimableOffers
|
|
1274
|
+
totalClaimableOffers.push(offer._id);
|
|
1275
1275
|
stats.claimable = true;
|
|
1276
1276
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1277
1277
|
}
|
|
@@ -1284,7 +1284,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1284
1284
|
}
|
|
1285
1285
|
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1286
1286
|
if (stats.claimable) {
|
|
1287
|
-
totalClaimableOffers =
|
|
1287
|
+
totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
|
|
1288
1288
|
}
|
|
1289
1289
|
stats.claimable = false;
|
|
1290
1290
|
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
@@ -1367,7 +1367,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1367
1367
|
stats.message = 'You already have an offer applied to your order.';
|
|
1368
1368
|
}
|
|
1369
1369
|
else {
|
|
1370
|
-
totalClaimableOffers
|
|
1370
|
+
totalClaimableOffers.push(offer._id);
|
|
1371
1371
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1372
1372
|
}
|
|
1373
1373
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1393,7 +1393,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1393
1393
|
stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
|
|
1394
1394
|
stats.claimable = isClaimable;
|
|
1395
1395
|
if (isClaimable) {
|
|
1396
|
-
totalClaimableOffers
|
|
1396
|
+
totalClaimableOffers.push(offer._id);
|
|
1397
1397
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1398
1398
|
}
|
|
1399
1399
|
else {
|
|
@@ -1417,7 +1417,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1417
1417
|
stats.message = 'This offer is redeemed ✅';
|
|
1418
1418
|
}
|
|
1419
1419
|
else {
|
|
1420
|
-
totalClaimableOffers
|
|
1420
|
+
totalClaimableOffers.push(offer._id);
|
|
1421
1421
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1422
1422
|
}
|
|
1423
1423
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1450,7 +1450,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1450
1450
|
stats.message = 'This offer is redeemed ✅';
|
|
1451
1451
|
}
|
|
1452
1452
|
else {
|
|
1453
|
-
totalClaimableOffers
|
|
1453
|
+
totalClaimableOffers.push(offer._id);
|
|
1454
1454
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1455
1455
|
}
|
|
1456
1456
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1479,7 +1479,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1479
1479
|
stats.message = 'This offer is redeemed ✅';
|
|
1480
1480
|
}
|
|
1481
1481
|
else {
|
|
1482
|
-
totalClaimableOffers
|
|
1482
|
+
totalClaimableOffers.push(offer._id);
|
|
1483
1483
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1484
1484
|
}
|
|
1485
1485
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1512,7 +1512,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1512
1512
|
stats.message = 'This offer is redeemed ✅';
|
|
1513
1513
|
}
|
|
1514
1514
|
else {
|
|
1515
|
-
totalClaimableOffers
|
|
1515
|
+
totalClaimableOffers.push(offer._id);
|
|
1516
1516
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1517
1517
|
}
|
|
1518
1518
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1530,7 +1530,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1530
1530
|
stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
|
|
1531
1531
|
stats.claimable = isClaimable;
|
|
1532
1532
|
if (isClaimable) {
|
|
1533
|
-
totalClaimableOffers
|
|
1533
|
+
totalClaimableOffers.push(offer._id);
|
|
1534
1534
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1535
1535
|
}
|
|
1536
1536
|
else {
|
|
@@ -1541,7 +1541,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1541
1541
|
}
|
|
1542
1542
|
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1543
1543
|
if (stats.claimable) {
|
|
1544
|
-
totalClaimableOffers =
|
|
1544
|
+
totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
|
|
1545
1545
|
}
|
|
1546
1546
|
stats.claimable = false;
|
|
1547
1547
|
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
@@ -1575,18 +1575,21 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1575
1575
|
});
|
|
1576
1576
|
totalLoyaltyPointsOfCustomer = loyaltyPoints;
|
|
1577
1577
|
}
|
|
1578
|
-
const
|
|
1578
|
+
const orderLevelClaimSignal = order_discount_details?.loyalty_discount_id === offer._id ? 1 : 0;
|
|
1579
|
+
const redeemedTimesForCurrentOffer = Math.max(getOfferRedeemedTimes(offer._id), orderLevelClaimSignal);
|
|
1580
|
+
const effectiveLoyaltyPointsForCurrentOffer = (totalLoyaltyPointsOfCustomer ?? 0) + redeemedTimesForCurrentOffer * (num_of_points ?? 0);
|
|
1581
|
+
const pointsProgress = getPreUnlockProgressPercentage(effectiveLoyaltyPointsForCurrentOffer, num_of_points || 1);
|
|
1579
1582
|
const amountProgress = getPreUnlockProgressPercentage(orderValue, total_amount || 1);
|
|
1580
1583
|
const combinedProgress = Math.min(pointsProgress, amountProgress);
|
|
1581
|
-
if (
|
|
1584
|
+
if (effectiveLoyaltyPointsForCurrentOffer >= num_of_points) {
|
|
1582
1585
|
if (orderValue >= total_amount) {
|
|
1583
|
-
if (
|
|
1586
|
+
if (effectiveLoyaltyPointsForCurrentOffer >= num_of_points) {
|
|
1584
1587
|
stats.progress = 100;
|
|
1585
1588
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1586
1589
|
}
|
|
1587
1590
|
else {
|
|
1588
1591
|
stats.progress = combinedProgress;
|
|
1589
|
-
stats.message = `You are ${(num_of_points -
|
|
1592
|
+
stats.message = `You are ${(num_of_points - effectiveLoyaltyPointsForCurrentOffer).toFixed(0)} points away from unlocking this offer`;
|
|
1590
1593
|
}
|
|
1591
1594
|
}
|
|
1592
1595
|
else {
|
|
@@ -1596,10 +1599,10 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1596
1599
|
}
|
|
1597
1600
|
else {
|
|
1598
1601
|
stats.progress = combinedProgress;
|
|
1599
|
-
stats.message = `You are ${(num_of_points -
|
|
1602
|
+
stats.message = `You are ${(num_of_points - effectiveLoyaltyPointsForCurrentOffer).toFixed(0)} points away from unlocking this offer`;
|
|
1600
1603
|
}
|
|
1601
1604
|
if (stats.progress >= 100) {
|
|
1602
|
-
const pointBurnTimes = Math.floor(
|
|
1605
|
+
const pointBurnTimes = Math.floor(effectiveLoyaltyPointsForCurrentOffer / (num_of_points || 1));
|
|
1603
1606
|
const amountTimes = Math.floor(orderValue / (total_amount || 1));
|
|
1604
1607
|
const totalUnlockableClaims = Math.min(pointBurnTimes, amountTimes, maxClaimsPerOrder);
|
|
1605
1608
|
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
@@ -1613,7 +1616,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1613
1616
|
offersWithStats.push({ offer, stats });
|
|
1614
1617
|
continue;
|
|
1615
1618
|
}
|
|
1616
|
-
const redeemedTimes =
|
|
1619
|
+
const redeemedTimes = redeemedTimesForCurrentOffer;
|
|
1617
1620
|
const isRedeemed = redeemedTimes > 0;
|
|
1618
1621
|
const discountSlotOccupied = isDiscountSlotOccupiedForOffer(offer);
|
|
1619
1622
|
stats.redeemed_times = redeemedTimes;
|
|
@@ -1626,7 +1629,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1626
1629
|
stats.message = 'You already have an offer applied to your order.';
|
|
1627
1630
|
}
|
|
1628
1631
|
else {
|
|
1629
|
-
totalClaimableOffers
|
|
1632
|
+
totalClaimableOffers.push(offer._id);
|
|
1630
1633
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1631
1634
|
}
|
|
1632
1635
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1653,7 +1656,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1653
1656
|
stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
|
|
1654
1657
|
stats.claimable = isClaimable;
|
|
1655
1658
|
if (isClaimable) {
|
|
1656
|
-
totalClaimableOffers
|
|
1659
|
+
totalClaimableOffers.push(offer._id);
|
|
1657
1660
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1658
1661
|
}
|
|
1659
1662
|
else {
|
|
@@ -1677,7 +1680,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1677
1680
|
stats.message = 'This offer is redeemed ✅';
|
|
1678
1681
|
}
|
|
1679
1682
|
else {
|
|
1680
|
-
totalClaimableOffers
|
|
1683
|
+
totalClaimableOffers.push(offer._id);
|
|
1681
1684
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1682
1685
|
}
|
|
1683
1686
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1710,7 +1713,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1710
1713
|
stats.message = 'This offer is redeemed ✅';
|
|
1711
1714
|
}
|
|
1712
1715
|
else {
|
|
1713
|
-
totalClaimableOffers
|
|
1716
|
+
totalClaimableOffers.push(offer._id);
|
|
1714
1717
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1715
1718
|
}
|
|
1716
1719
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1739,7 +1742,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1739
1742
|
stats.message = 'This offer is redeemed ✅';
|
|
1740
1743
|
}
|
|
1741
1744
|
else {
|
|
1742
|
-
totalClaimableOffers
|
|
1745
|
+
totalClaimableOffers.push(offer._id);
|
|
1743
1746
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1744
1747
|
}
|
|
1745
1748
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1772,7 +1775,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1772
1775
|
stats.message = 'This offer is redeemed ✅';
|
|
1773
1776
|
}
|
|
1774
1777
|
else {
|
|
1775
|
-
totalClaimableOffers
|
|
1778
|
+
totalClaimableOffers.push(offer._id);
|
|
1776
1779
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1777
1780
|
}
|
|
1778
1781
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1791,7 +1794,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1791
1794
|
stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
|
|
1792
1795
|
stats.claimable = isClaimable;
|
|
1793
1796
|
if (isClaimable) {
|
|
1794
|
-
totalClaimableOffers
|
|
1797
|
+
totalClaimableOffers.push(offer._id);
|
|
1795
1798
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1796
1799
|
}
|
|
1797
1800
|
else {
|
|
@@ -1802,7 +1805,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1802
1805
|
}
|
|
1803
1806
|
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
1804
1807
|
if (stats.claimable) {
|
|
1805
|
-
totalClaimableOffers =
|
|
1808
|
+
totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
|
|
1806
1809
|
}
|
|
1807
1810
|
stats.claimable = false;
|
|
1808
1811
|
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|
|
@@ -1888,7 +1891,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1888
1891
|
stats.message = 'You already have an offer applied to your order.';
|
|
1889
1892
|
}
|
|
1890
1893
|
else {
|
|
1891
|
-
totalClaimableOffers
|
|
1894
|
+
totalClaimableOffers.push(offer._id);
|
|
1892
1895
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1893
1896
|
}
|
|
1894
1897
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1916,7 +1919,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1916
1919
|
stats.applicable_quantity = applicableQuantity * maxRedeemableClaims;
|
|
1917
1920
|
stats.claimable = isClaimable;
|
|
1918
1921
|
if (isClaimable) {
|
|
1919
|
-
totalClaimableOffers
|
|
1922
|
+
totalClaimableOffers.push(offer._id);
|
|
1920
1923
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1921
1924
|
}
|
|
1922
1925
|
else {
|
|
@@ -1946,7 +1949,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1946
1949
|
stats.message = 'This offer is redeemed ✅';
|
|
1947
1950
|
}
|
|
1948
1951
|
else {
|
|
1949
|
-
totalClaimableOffers
|
|
1952
|
+
totalClaimableOffers.push(offer._id);
|
|
1950
1953
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1951
1954
|
}
|
|
1952
1955
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -1979,7 +1982,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
1979
1982
|
stats.message = 'This offer is redeemed ✅';
|
|
1980
1983
|
}
|
|
1981
1984
|
else {
|
|
1982
|
-
totalClaimableOffers
|
|
1985
|
+
totalClaimableOffers.push(offer._id);
|
|
1983
1986
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
1984
1987
|
}
|
|
1985
1988
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -2014,7 +2017,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
2014
2017
|
stats.message = 'This offer is redeemed ✅';
|
|
2015
2018
|
}
|
|
2016
2019
|
else {
|
|
2017
|
-
totalClaimableOffers
|
|
2020
|
+
totalClaimableOffers.push(offer._id);
|
|
2018
2021
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
2019
2022
|
}
|
|
2020
2023
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -2047,7 +2050,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
2047
2050
|
stats.message = 'This offer is redeemed ✅';
|
|
2048
2051
|
}
|
|
2049
2052
|
else {
|
|
2050
|
-
totalClaimableOffers
|
|
2053
|
+
totalClaimableOffers.push(offer._id);
|
|
2051
2054
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
2052
2055
|
}
|
|
2053
2056
|
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
@@ -2066,7 +2069,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
2066
2069
|
stats.applicable_quantity = applicableQuantity;
|
|
2067
2070
|
stats.claimable = isClaimable;
|
|
2068
2071
|
if (isClaimable) {
|
|
2069
|
-
totalClaimableOffers
|
|
2072
|
+
totalClaimableOffers.push(offer._id);
|
|
2070
2073
|
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
2071
2074
|
}
|
|
2072
2075
|
else {
|
|
@@ -2077,7 +2080,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
|
|
|
2077
2080
|
}
|
|
2078
2081
|
if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
|
|
2079
2082
|
if (stats.claimable) {
|
|
2080
|
-
totalClaimableOffers =
|
|
2083
|
+
totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
|
|
2081
2084
|
}
|
|
2082
2085
|
stats.claimable = false;
|
|
2083
2086
|
stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
|