foodbot-cart-calculations 1.0.39 → 1.0.40
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.
|
@@ -55,6 +55,7 @@ function offerCalculation(carts, offer) {
|
|
|
55
55
|
reject(error);
|
|
56
56
|
})
|
|
57
57
|
} else if (offer && offer.offer_discount_type && (offer.offer_discount_type == 'discount' || offer.offer_discount_type == 'manual')) {
|
|
58
|
+
|
|
58
59
|
getCategorySpeificOffer(carts, offer).then(res => {
|
|
59
60
|
carts = res
|
|
60
61
|
|
|
@@ -120,13 +121,15 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
120
121
|
if (parseFloat(offer.oo_min_amount) <= parseFloat(afterTotal)) {
|
|
121
122
|
|
|
122
123
|
if (offer.offer_discount_type != 'manual')
|
|
123
|
-
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(
|
|
124
|
+
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(val =>
|
|
125
|
+
val.toString().length > 10 ? val : Number(val)
|
|
126
|
+
);
|
|
124
127
|
|
|
125
128
|
if (offer.offer_discount_type != 'manual')
|
|
126
129
|
if (offer.offer_products.package_items) {
|
|
127
|
-
offer.offer_products.package_items = offer.offer_products.package_items.map(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
offer.offer_products.package_items = offer.offer_products.package_items.map(x =>
|
|
131
|
+
x.toString().length > 10 ? x : parseInt(x, 10)
|
|
132
|
+
);
|
|
130
133
|
}
|
|
131
134
|
else {
|
|
132
135
|
offer.offer_products.package_items = []
|
|
@@ -134,7 +137,8 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
134
137
|
|
|
135
138
|
let foundItemsSum = 0
|
|
136
139
|
carts.item_details.filter((res) => {
|
|
137
|
-
|
|
140
|
+
let itemId = res.item_id.toString().length > 10 ? res.item_id : parseInt(res.item_id);
|
|
141
|
+
if (!res.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(itemId) && res.isPackage == 0) || (offer.offer_products.package_items.includes(itemId) && res.isPackage == 1))) {
|
|
138
142
|
|
|
139
143
|
foundItemsSum = foundItemsSum + res.item_price_with_modifier * res.quantity
|
|
140
144
|
return foundItemsSum
|
|
@@ -144,8 +148,8 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
144
148
|
let offerAmount = (offer.oo_offer_value <= foundItemsSum) ? offer.oo_offer_value : foundItemsSum;
|
|
145
149
|
let remaningOfferAmount = offerAmount
|
|
146
150
|
carts.item_details.forEach((element, index) => {
|
|
147
|
-
|
|
148
|
-
if (!element.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(
|
|
151
|
+
let itemId = element.item_id.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
152
|
+
if (!element.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(itemId) && element.isPackage == 0) || (offer.offer_products.package_items.includes(itemId) && element.isPackage == 1))) {
|
|
149
153
|
var itemAmount = 0;
|
|
150
154
|
|
|
151
155
|
// Apply discount on Packages
|
|
@@ -732,10 +736,15 @@ function addItemQuantity(items, offer) {
|
|
|
732
736
|
try {
|
|
733
737
|
var finalItems = [];
|
|
734
738
|
var count = 0;
|
|
735
|
-
offer.offer_products.offer_buy_products=offer.offer_products.offer_buy_products.map(item =>
|
|
736
|
-
|
|
739
|
+
offer.offer_products.offer_buy_products=offer.offer_products.offer_buy_products.map(item =>
|
|
740
|
+
item.toString().length > 10 ? item : parseInt(item, 10)
|
|
741
|
+
);
|
|
742
|
+
offer.offer_products.offer_get_products=offer.offer_products.offer_get_products.map(item =>
|
|
743
|
+
item.toString().length > 10 ? item : parseInt(item, 10)
|
|
744
|
+
);
|
|
737
745
|
items.forEach(function (element) {
|
|
738
|
-
|
|
746
|
+
let itemId = element.item_id.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
747
|
+
if (offer.offer_products.offer_buy_products.includes(itemId) || offer.offer_products.offer_get_products.includes(itemId)) {
|
|
739
748
|
for (var i = 1; i <= element.quantity; i++) {
|
|
740
749
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
741
750
|
var amount = element.item_price;
|
|
@@ -743,9 +752,9 @@ function addItemQuantity(items, offer) {
|
|
|
743
752
|
if (offer.offer_products.modifier_category.includes('all') || offer.offer_products.modifier_category.includes('All')) {
|
|
744
753
|
amount = element.item_price_with_modifier;
|
|
745
754
|
} else {
|
|
746
|
-
offer.offer_products.modifier_category = offer.offer_products.modifier_category.map(
|
|
747
|
-
|
|
748
|
-
|
|
755
|
+
offer.offer_products.modifier_category = offer.offer_products.modifier_category.map(x =>
|
|
756
|
+
x.toString().length > 10 ? x : parseInt(x, 10)
|
|
757
|
+
);
|
|
749
758
|
var modifiers = [];
|
|
750
759
|
element.item_modifiers.forEach(function (modifier) {
|
|
751
760
|
|
|
@@ -761,8 +770,8 @@ function addItemQuantity(items, offer) {
|
|
|
761
770
|
'item_id': element.item_id,
|
|
762
771
|
'amount': amount,
|
|
763
772
|
'item': item,
|
|
764
|
-
'buy': offer.offer_products.offer_buy_products.includes(
|
|
765
|
-
'get': offer.offer_products.offer_get_products.includes(
|
|
773
|
+
'buy': offer.offer_products.offer_buy_products.includes(itemId),
|
|
774
|
+
'get': offer.offer_products.offer_get_products.includes(itemId)
|
|
766
775
|
});
|
|
767
776
|
} else {
|
|
768
777
|
finalItems.push({
|
|
@@ -770,8 +779,8 @@ function addItemQuantity(items, offer) {
|
|
|
770
779
|
'item_id': element.item_id,
|
|
771
780
|
// / element.quantity
|
|
772
781
|
'amount': element.item_price,
|
|
773
|
-
'buy': offer.offer_products.offer_buy_products.includes(
|
|
774
|
-
'get': offer.offer_products.offer_get_products.includes(
|
|
782
|
+
'buy': offer.offer_products.offer_buy_products.includes(itemId),
|
|
783
|
+
'get': offer.offer_products.offer_get_products.includes(itemId)
|
|
775
784
|
});
|
|
776
785
|
}
|
|
777
786
|
}
|
|
@@ -812,7 +821,9 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
812
821
|
var total = 0;
|
|
813
822
|
var count = 0;
|
|
814
823
|
var offerAmount = offer.oo_offer_value;
|
|
815
|
-
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(
|
|
824
|
+
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(val =>
|
|
825
|
+
val.toString().length > 10 ? val : Number(val)
|
|
826
|
+
);
|
|
816
827
|
|
|
817
828
|
var cartItem = carts;
|
|
818
829
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
@@ -832,7 +843,8 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
832
843
|
cartItem.forEach((element, index) => {
|
|
833
844
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
834
845
|
|
|
835
|
-
|
|
846
|
+
let itemId = element.item_id.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
847
|
+
if (offer.offer_products.offer_discount_products.includes(itemId)) {
|
|
836
848
|
var offerAmount = 0;
|
|
837
849
|
let costWithOutModifier = 0;
|
|
838
850
|
var singleItemCost = element.item_price;
|
|
@@ -851,9 +863,9 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
851
863
|
singleItemCost = singleItemCost + singModPrice;
|
|
852
864
|
});
|
|
853
865
|
} else {
|
|
854
|
-
offer.offer_products.modifier_category = offer.offer_products.modifier_category.map(
|
|
855
|
-
|
|
856
|
-
|
|
866
|
+
offer.offer_products.modifier_category = offer.offer_products.modifier_category.map(x =>
|
|
867
|
+
x.toString().length > 10 ? x : parseInt(x, 10)
|
|
868
|
+
);
|
|
857
869
|
|
|
858
870
|
element.item_modifiers.forEach((modifier, modiIndex) => {
|
|
859
871
|
if (offer.offer_products.modifier_category.includes(modifier.modifier_category_id)) {
|
|
@@ -942,14 +954,19 @@ function getFixedPriceProductOffer(cartObject, offer) {
|
|
|
942
954
|
var count = 0;
|
|
943
955
|
var fixedPrice = offer.oo_offer_value;
|
|
944
956
|
|
|
945
|
-
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(
|
|
946
|
-
|
|
957
|
+
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(val =>
|
|
958
|
+
val.toString().length > 10 ? val : Number(val)
|
|
959
|
+
);
|
|
960
|
+
offer.offer_products.package_items = offer.offer_products.package_items.map(x =>
|
|
961
|
+
x.toString().length > 10 ? x : parseInt(x, 10)
|
|
962
|
+
);
|
|
947
963
|
|
|
948
964
|
var cartItem = carts;
|
|
949
965
|
|
|
950
966
|
cartItem.forEach((element, index) => {
|
|
951
967
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
952
|
-
|
|
968
|
+
let itemId = element.item_id.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
969
|
+
if (offer.offer_products.offer_discount_products.includes(itemId) || offer.offer_products.package_items.includes(itemId)) {
|
|
953
970
|
var offerAmount = 0;
|
|
954
971
|
var singleItemCost = element.item_price;
|
|
955
972
|
|
package/package.json
CHANGED