foodbot-cart-calculations 1.0.37 → 1.0.39
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.
|
@@ -120,15 +120,12 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
120
120
|
if (parseFloat(offer.oo_min_amount) <= parseFloat(afterTotal)) {
|
|
121
121
|
|
|
122
122
|
if (offer.offer_discount_type != 'manual')
|
|
123
|
-
|
|
124
|
-
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(x =>
|
|
125
|
-
typeof x === "string" && !isNaN(x) ? Number(x) : x
|
|
126
|
-
);
|
|
123
|
+
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(Number);
|
|
127
124
|
|
|
128
125
|
if (offer.offer_discount_type != 'manual')
|
|
129
126
|
if (offer.offer_products.package_items) {
|
|
130
127
|
offer.offer_products.package_items = offer.offer_products.package_items.map(function (x) {
|
|
131
|
-
return (x);
|
|
128
|
+
return parseInt(x, 10);
|
|
132
129
|
});
|
|
133
130
|
}
|
|
134
131
|
else {
|
|
@@ -137,7 +134,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
137
134
|
|
|
138
135
|
let foundItemsSum = 0
|
|
139
136
|
carts.item_details.filter((res) => {
|
|
140
|
-
if (!res.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes((res.item_id)) && res.isPackage == 0) || (offer.offer_products.package_items.includes((res.item_id)) && res.isPackage == 1))) {
|
|
137
|
+
if (!res.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(parseInt(res.item_id)) && res.isPackage == 0) || (offer.offer_products.package_items.includes(parseInt(res.item_id)) && res.isPackage == 1))) {
|
|
141
138
|
|
|
142
139
|
foundItemsSum = foundItemsSum + res.item_price_with_modifier * res.quantity
|
|
143
140
|
return foundItemsSum
|
|
@@ -148,7 +145,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
148
145
|
let remaningOfferAmount = offerAmount
|
|
149
146
|
carts.item_details.forEach((element, index) => {
|
|
150
147
|
|
|
151
|
-
if (!element.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes((element.item_id)) && element.isPackage == 0) || (offer.offer_products.package_items.includes((element.item_id)) && element.isPackage == 1))) {
|
|
148
|
+
if (!element.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(parseInt(element.item_id)) && element.isPackage == 0) || (offer.offer_products.package_items.includes(parseInt(element.item_id)) && element.isPackage == 1))) {
|
|
152
149
|
var itemAmount = 0;
|
|
153
150
|
|
|
154
151
|
// Apply discount on Packages
|
|
@@ -362,7 +359,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
362
359
|
count++
|
|
363
360
|
}
|
|
364
361
|
|
|
365
|
-
// console.log("count",
|
|
362
|
+
// console.log("count", count)
|
|
366
363
|
if (count == carts.item_details.length && carts.item_details) {
|
|
367
364
|
if ((Number(total) < Number(offerAmount) || Number(total) > Number(offerAmount)) && offer.oo_offer_type != 'percentage') {
|
|
368
365
|
let difference = Number(offerAmount) - Number(total)
|
|
@@ -735,10 +732,10 @@ function addItemQuantity(items, offer) {
|
|
|
735
732
|
try {
|
|
736
733
|
var finalItems = [];
|
|
737
734
|
var count = 0;
|
|
738
|
-
offer.offer_products.offer_buy_products=offer.offer_products.offer_buy_products.map(item => (item));
|
|
739
|
-
offer.offer_products.offer_get_products=offer.offer_products.offer_get_products.map(item => (item));
|
|
735
|
+
offer.offer_products.offer_buy_products=offer.offer_products.offer_buy_products.map(item => parseInt(item, 10));
|
|
736
|
+
offer.offer_products.offer_get_products=offer.offer_products.offer_get_products.map(item => parseInt(item, 10));
|
|
740
737
|
items.forEach(function (element) {
|
|
741
|
-
if (offer.offer_products.offer_buy_products.includes((element.item_id)) || offer.offer_products.offer_get_products.includes((element.item_id))) {
|
|
738
|
+
if (offer.offer_products.offer_buy_products.includes(parseInt(element.item_id)) || offer.offer_products.offer_get_products.includes(parseInt(element.item_id))) {
|
|
742
739
|
for (var i = 1; i <= element.quantity; i++) {
|
|
743
740
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
744
741
|
var amount = element.item_price;
|
|
@@ -747,7 +744,7 @@ function addItemQuantity(items, offer) {
|
|
|
747
744
|
amount = element.item_price_with_modifier;
|
|
748
745
|
} else {
|
|
749
746
|
offer.offer_products.modifier_category = offer.offer_products.modifier_category.map(function (x) {
|
|
750
|
-
return (x);
|
|
747
|
+
return parseInt(x, 10);
|
|
751
748
|
});
|
|
752
749
|
var modifiers = [];
|
|
753
750
|
element.item_modifiers.forEach(function (modifier) {
|
|
@@ -764,8 +761,8 @@ function addItemQuantity(items, offer) {
|
|
|
764
761
|
'item_id': element.item_id,
|
|
765
762
|
'amount': amount,
|
|
766
763
|
'item': item,
|
|
767
|
-
'buy': offer.offer_products.offer_buy_products.includes((element.item_id)),
|
|
768
|
-
'get': offer.offer_products.offer_get_products.includes((element.item_id))
|
|
764
|
+
'buy': offer.offer_products.offer_buy_products.includes(parseInt(element.item_id)),
|
|
765
|
+
'get': offer.offer_products.offer_get_products.includes(parseInt(element.item_id))
|
|
769
766
|
});
|
|
770
767
|
} else {
|
|
771
768
|
finalItems.push({
|
|
@@ -773,8 +770,8 @@ function addItemQuantity(items, offer) {
|
|
|
773
770
|
'item_id': element.item_id,
|
|
774
771
|
// / element.quantity
|
|
775
772
|
'amount': element.item_price,
|
|
776
|
-
'buy': offer.offer_products.offer_buy_products.includes((element.item_id)),
|
|
777
|
-
'get': offer.offer_products.offer_get_products.includes((element.item_id))
|
|
773
|
+
'buy': offer.offer_products.offer_buy_products.includes(parseInt(element.item_id)),
|
|
774
|
+
'get': offer.offer_products.offer_get_products.includes(parseInt(element.item_id))
|
|
778
775
|
});
|
|
779
776
|
}
|
|
780
777
|
}
|
|
@@ -815,10 +812,7 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
815
812
|
var total = 0;
|
|
816
813
|
var count = 0;
|
|
817
814
|
var offerAmount = offer.oo_offer_value;
|
|
818
|
-
|
|
819
|
-
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(x =>
|
|
820
|
-
typeof x === "string" && !isNaN(x) ? Number(x) : x
|
|
821
|
-
);
|
|
815
|
+
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(Number);
|
|
822
816
|
|
|
823
817
|
var cartItem = carts;
|
|
824
818
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
@@ -838,7 +832,7 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
838
832
|
cartItem.forEach((element, index) => {
|
|
839
833
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
840
834
|
|
|
841
|
-
if (offer.offer_products.offer_discount_products.includes((element.item_id))) {
|
|
835
|
+
if (offer.offer_products.offer_discount_products.includes(parseInt(element.item_id))) {
|
|
842
836
|
var offerAmount = 0;
|
|
843
837
|
let costWithOutModifier = 0;
|
|
844
838
|
var singleItemCost = element.item_price;
|
|
@@ -858,7 +852,7 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
858
852
|
});
|
|
859
853
|
} else {
|
|
860
854
|
offer.offer_products.modifier_category = offer.offer_products.modifier_category.map(function (x) {
|
|
861
|
-
return (x);
|
|
855
|
+
return parseInt(x, 10);
|
|
862
856
|
});
|
|
863
857
|
|
|
864
858
|
element.item_modifiers.forEach((modifier, modiIndex) => {
|
|
@@ -948,20 +942,14 @@ function getFixedPriceProductOffer(cartObject, offer) {
|
|
|
948
942
|
var count = 0;
|
|
949
943
|
var fixedPrice = offer.oo_offer_value;
|
|
950
944
|
|
|
951
|
-
|
|
952
|
-
offer.offer_products.
|
|
953
|
-
typeof x === "string" && !isNaN(x) ? Number(x) : x
|
|
954
|
-
);
|
|
955
|
-
// offer.offer_products.package_items = offer.offer_products.package_items.map(Number);
|
|
956
|
-
offer.offer_products.package_items = offer.offer_products.package_items.map(x =>
|
|
957
|
-
typeof x === "string" && !isNaN(x) ? Number(x) : x
|
|
958
|
-
);
|
|
945
|
+
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(Number);
|
|
946
|
+
offer.offer_products.package_items = offer.offer_products.package_items.map(Number);
|
|
959
947
|
|
|
960
948
|
var cartItem = carts;
|
|
961
949
|
|
|
962
950
|
cartItem.forEach((element, index) => {
|
|
963
951
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
964
|
-
if (offer.offer_products.offer_discount_products.includes((element.item_id)) || offer.offer_products.package_items.includes((element.item_id))) {
|
|
952
|
+
if (offer.offer_products.offer_discount_products.includes(parseInt(element.item_id)) || offer.offer_products.package_items.includes(parseInt(element.item_id))) {
|
|
965
953
|
var offerAmount = 0;
|
|
966
954
|
var singleItemCost = element.item_price;
|
|
967
955
|
|
package/package.json
CHANGED