foodbot-cart-calculations 1.0.37 → 1.0.38
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.
|
@@ -35,7 +35,7 @@ function offerCalculation(carts, offer) {
|
|
|
35
35
|
if (offer && offer.offer_discount_type && offer.offer_discount_type == 'buy_x_get_y') {
|
|
36
36
|
getOfferDetails(carts, offer).then(res => {
|
|
37
37
|
carts = res
|
|
38
|
-
console.log("res",res)
|
|
38
|
+
// console.log("res",res)
|
|
39
39
|
if (offer && offer.oo_offer_type == 'percentage' && offer.discount_roundoff && offer.discount_roundoff == 1) {
|
|
40
40
|
|
|
41
41
|
// offer.oo_offer_types = JSON.parse(JSON.stringify(offer.oo_offer_type))
|
|
@@ -137,7 +137,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
137
137
|
|
|
138
138
|
let foundItemsSum = 0
|
|
139
139
|
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))) {
|
|
140
|
+
if (!res.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(String(res.item_id)) && res.isPackage == 0) || (offer.offer_products.package_items.includes(String(res.item_id)) && res.isPackage == 1))) {
|
|
141
141
|
|
|
142
142
|
foundItemsSum = foundItemsSum + res.item_price_with_modifier * res.quantity
|
|
143
143
|
return foundItemsSum
|
|
@@ -148,7 +148,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
148
148
|
let remaningOfferAmount = offerAmount
|
|
149
149
|
carts.item_details.forEach((element, index) => {
|
|
150
150
|
|
|
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))) {
|
|
151
|
+
if (!element.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(String(element.item_id)) && element.isPackage == 0) || (offer.offer_products.package_items.includes(String(element.item_id)) && element.isPackage == 1))) {
|
|
152
152
|
var itemAmount = 0;
|
|
153
153
|
|
|
154
154
|
// Apply discount on Packages
|
|
@@ -628,14 +628,14 @@ function getBuyxGetYOnCondition(descending, cartData, offer,total,buyItemAmount,
|
|
|
628
628
|
function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total) {
|
|
629
629
|
return new Promise(function (resolve, reject) {
|
|
630
630
|
try {
|
|
631
|
-
console.log("ooooooooooooooo",JSON.parse(JSON.stringify(offer)))
|
|
631
|
+
// console.log("ooooooooooooooo",JSON.parse(JSON.stringify(offer)))
|
|
632
632
|
let offerAmount = offer.oo_offer_value;
|
|
633
633
|
let singlePriceDiscount = offerAmount / buyItemAmount;
|
|
634
634
|
singlePriceDiscount = parseFloat(singlePriceDiscount).toFixed(6);
|
|
635
635
|
let remaningOfferAmount = offer.oo_offer_value;
|
|
636
636
|
let count = 0;
|
|
637
637
|
let carts = cartObject.item_details;
|
|
638
|
-
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",buyItemss,total)
|
|
638
|
+
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",buyItemss,total)
|
|
639
639
|
if(buyItemss && buyItemss.length>0){
|
|
640
640
|
buyItemss.forEach((element, buyIndex) => {
|
|
641
641
|
let itemAmount = 0;
|
|
@@ -648,7 +648,7 @@ function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total)
|
|
|
648
648
|
return obj.item_id == element.item_id;
|
|
649
649
|
});
|
|
650
650
|
|
|
651
|
-
console.log("carts index",carts,itemIndex)
|
|
651
|
+
// console.log("carts index",carts,itemIndex)
|
|
652
652
|
|
|
653
653
|
if ( !carts[itemIndex].promotion_discount_modifier) carts[itemIndex].promotion_discount_modifier = 0;
|
|
654
654
|
|
|
@@ -738,7 +738,7 @@ function addItemQuantity(items, offer) {
|
|
|
738
738
|
offer.offer_products.offer_buy_products=offer.offer_products.offer_buy_products.map(item => (item));
|
|
739
739
|
offer.offer_products.offer_get_products=offer.offer_products.offer_get_products.map(item => (item));
|
|
740
740
|
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))) {
|
|
741
|
+
if (offer.offer_products.offer_buy_products.includes(String(element.item_id)) || offer.offer_products.offer_get_products.includes(String(element.item_id))) {
|
|
742
742
|
for (var i = 1; i <= element.quantity; i++) {
|
|
743
743
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
744
744
|
var amount = element.item_price;
|
|
@@ -751,8 +751,7 @@ function addItemQuantity(items, offer) {
|
|
|
751
751
|
});
|
|
752
752
|
var modifiers = [];
|
|
753
753
|
element.item_modifiers.forEach(function (modifier) {
|
|
754
|
-
|
|
755
|
-
if (offer.offer_products.modifier_category.includes(modifier.modifier_category_id)) {
|
|
754
|
+
if (offer.offer_products.modifier_category.includes(String(modifier.modifier_category_id))) {
|
|
756
755
|
amount = amount + modifier.modifier_item_price;
|
|
757
756
|
modifiers.push(modifier);
|
|
758
757
|
}
|
|
@@ -764,8 +763,8 @@ function addItemQuantity(items, offer) {
|
|
|
764
763
|
'item_id': element.item_id,
|
|
765
764
|
'amount': amount,
|
|
766
765
|
'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))
|
|
766
|
+
'buy': offer.offer_products.offer_buy_products.includes(String(element.item_id)),
|
|
767
|
+
'get': offer.offer_products.offer_get_products.includes(String(element.item_id))
|
|
769
768
|
});
|
|
770
769
|
} else {
|
|
771
770
|
finalItems.push({
|
|
@@ -773,8 +772,8 @@ function addItemQuantity(items, offer) {
|
|
|
773
772
|
'item_id': element.item_id,
|
|
774
773
|
// / element.quantity
|
|
775
774
|
'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))
|
|
775
|
+
'buy': offer.offer_products.offer_buy_products.includes(String(element.item_id)),
|
|
776
|
+
'get': offer.offer_products.offer_get_products.includes(String(element.item_id))
|
|
778
777
|
});
|
|
779
778
|
}
|
|
780
779
|
}
|
|
@@ -838,7 +837,7 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
838
837
|
cartItem.forEach((element, index) => {
|
|
839
838
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
840
839
|
|
|
841
|
-
if (offer.offer_products.offer_discount_products.includes((element.item_id))) {
|
|
840
|
+
if (offer.offer_products.offer_discount_products.includes(String(element.item_id))) {
|
|
842
841
|
var offerAmount = 0;
|
|
843
842
|
let costWithOutModifier = 0;
|
|
844
843
|
var singleItemCost = element.item_price;
|
|
@@ -862,7 +861,7 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
862
861
|
});
|
|
863
862
|
|
|
864
863
|
element.item_modifiers.forEach((modifier, modiIndex) => {
|
|
865
|
-
if (offer.offer_products.modifier_category.includes(modifier.modifier_category_id)) {
|
|
864
|
+
if (offer.offer_products.modifier_category.includes(String(modifier.modifier_category_id))) {
|
|
866
865
|
let singModPrice1 = modifier.modifier_item_price * modifier.quantity;
|
|
867
866
|
|
|
868
867
|
if (!carts[ItemIndex].item_modifiers[modiIndex].promotion_discount)
|
|
@@ -961,7 +960,7 @@ function getFixedPriceProductOffer(cartObject, offer) {
|
|
|
961
960
|
|
|
962
961
|
cartItem.forEach((element, index) => {
|
|
963
962
|
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))) {
|
|
963
|
+
if (offer.offer_products.offer_discount_products.includes(String(element.item_id)) || offer.offer_products.package_items.includes(String(element.item_id))) {
|
|
965
964
|
var offerAmount = 0;
|
|
966
965
|
var singleItemCost = element.item_price;
|
|
967
966
|
|
package/package.json
CHANGED