foodbot-cart-calculations 1.0.42 → 1.0.43
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.
|
@@ -143,18 +143,19 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
143
143
|
|
|
144
144
|
let foundItemsSum = 0
|
|
145
145
|
carts.item_details.filter((res) => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
if(!res.purchase_points){
|
|
147
|
+
let itemId = res.item_id?.toString().length > 10 ? res.item_id : parseInt(res.item_id);
|
|
148
|
+
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))) {
|
|
149
|
+
foundItemsSum = foundItemsSum + res.item_price_with_modifier * res.quantity
|
|
150
|
+
return foundItemsSum
|
|
151
|
+
}
|
|
151
152
|
}
|
|
152
153
|
})
|
|
153
154
|
|
|
154
155
|
let offerAmount = (offer.oo_offer_value <= foundItemsSum) ? offer.oo_offer_value : foundItemsSum;
|
|
155
156
|
let remaningOfferAmount = offerAmount
|
|
156
157
|
carts.item_details.forEach((element, index) => {
|
|
157
|
-
let itemId = element.item_id
|
|
158
|
+
let itemId = element.item_id?.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
158
159
|
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))) {
|
|
159
160
|
var itemAmount = 0;
|
|
160
161
|
|
|
@@ -749,7 +750,7 @@ function addItemQuantity(items, offer) {
|
|
|
749
750
|
item.toString().length > 10 ? item : parseInt(item, 10)
|
|
750
751
|
);
|
|
751
752
|
items.forEach(function (element) {
|
|
752
|
-
let itemId = element.item_id
|
|
753
|
+
let itemId = element.item_id?.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
753
754
|
if (offer.offer_products.offer_buy_products.includes(itemId) || offer.offer_products.offer_get_products.includes(itemId)) {
|
|
754
755
|
for (var i = 1; i <= element.quantity; i++) {
|
|
755
756
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
@@ -849,7 +850,7 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
849
850
|
cartItem.forEach((element, index) => {
|
|
850
851
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
851
852
|
|
|
852
|
-
let itemId = element.item_id
|
|
853
|
+
let itemId = element.item_id?.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
853
854
|
if (offer.offer_products.offer_discount_products.includes(itemId)) {
|
|
854
855
|
var offerAmount = 0;
|
|
855
856
|
let costWithOutModifier = 0;
|
|
@@ -971,7 +972,7 @@ function getFixedPriceProductOffer(cartObject, offer) {
|
|
|
971
972
|
|
|
972
973
|
cartItem.forEach((element, index) => {
|
|
973
974
|
var ItemIndex = carts.findIndex((x) => x.item_id == element.item_id && !x.remove);
|
|
974
|
-
let itemId = element.item_id
|
|
975
|
+
let itemId = element.item_id?.toString().length > 10 ? element.item_id : parseInt(element.item_id);
|
|
975
976
|
if (offer.offer_products.offer_discount_products.includes(itemId) || offer.offer_products.package_items.includes(itemId)) {
|
|
976
977
|
var offerAmount = 0;
|
|
977
978
|
var singleItemCost = element.item_price;
|
|
@@ -1063,7 +1064,9 @@ function setPackageDefaultDiscount(cart) {
|
|
|
1063
1064
|
let itemTotal = 0;
|
|
1064
1065
|
if (item.package_items && item.package_items.length > 0) {
|
|
1065
1066
|
item.package_items.forEach(function (v) {
|
|
1066
|
-
|
|
1067
|
+
//this commemted code is sceniore when user can also increas item quantity i think which is wrong
|
|
1068
|
+
// itemTotal += ((item.quantity * v.quantity) * v.price);
|
|
1069
|
+
itemTotal += (item.quantity * v.price);
|
|
1067
1070
|
})
|
|
1068
1071
|
let packagePrice = item.quantity * item.item_price;
|
|
1069
1072
|
let totalDiscount = (packagePrice < itemTotal) ? (parseFloat(itemTotal) - parseFloat(packagePrice)).toFixed(2) : 0;
|
|
@@ -1101,10 +1104,11 @@ function distributeDiscount(packageItems, totalDiscount, itemTotal, quantity) {
|
|
|
1101
1104
|
let totalApplied = 0;
|
|
1102
1105
|
let singleUnit = (quantity * parseFloat(totalDiscount) / parseFloat(itemTotal)).toFixed(2);
|
|
1103
1106
|
for (const [index, item] of packageItems.entries()) {
|
|
1107
|
+
//this commemted code is sceniore when user can also increas item quantity i think which is wrong
|
|
1108
|
+
// let discountPerItem = (parseFloat(singleUnit) * (parseInt(item.quantity) * parseFloat(item.price))).toFixed(2);
|
|
1104
1109
|
let discountPerItem = (parseFloat(singleUnit) * parseFloat(item.price)).toFixed(2);
|
|
1105
1110
|
totalApplied = (parseFloat(totalApplied) + parseFloat(discountPerItem)).toFixed(2);
|
|
1106
1111
|
item.default_combo_discount = parseFloat(discountPerItem).toFixed(2);
|
|
1107
|
-
|
|
1108
1112
|
if (index == packageItems.length - 1) {
|
|
1109
1113
|
|
|
1110
1114
|
let remaningOfferAmount = (parseFloat(totalDiscount) - parseFloat(totalApplied)).toFixed(2);
|
package/package.json
CHANGED