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