foodbot-cart-calculations 1.0.53 → 1.0.55
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.
|
@@ -1081,10 +1081,17 @@ function setPackageDefaultDiscount(cart) {
|
|
|
1081
1081
|
item.package_items.forEach(function (v) {
|
|
1082
1082
|
//this commemted code is sceniore when user can also increas item quantity i think which is wrong
|
|
1083
1083
|
// itemTotal += ((item.quantity * v.quantity) * v.price);
|
|
1084
|
-
|
|
1084
|
+
if(item.quantity > 1){
|
|
1085
|
+
itemTotal += (v.quantity * v.price);
|
|
1086
|
+
}else{
|
|
1087
|
+
itemTotal += (item.quantity * (v.quantity * v.price));
|
|
1088
|
+
}
|
|
1085
1089
|
})
|
|
1086
1090
|
let packagePrice = item.quantity * item.item_price;
|
|
1091
|
+
// console.log(packagePrice);
|
|
1087
1092
|
let totalDiscount = (packagePrice < itemTotal) ? (parseFloat(itemTotal) - parseFloat(packagePrice)).toFixed(2) : 0;
|
|
1093
|
+
// console.log(itemTotal);
|
|
1094
|
+
// console.log(totalDiscount);
|
|
1088
1095
|
await distributeDiscount(item.package_items, totalDiscount, itemTotal, item.quantity).then(ele => {
|
|
1089
1096
|
item.package_items = ele;
|
|
1090
1097
|
if (index == cart.item_details.length - 1) {
|
|
@@ -1121,11 +1128,10 @@ function distributeDiscount(packageItems, totalDiscount, itemTotal, quantity) {
|
|
|
1121
1128
|
for (const [index, item] of packageItems.entries()) {
|
|
1122
1129
|
//this commemted code is sceniore when user can also increas item quantity i think which is wrong
|
|
1123
1130
|
// let discountPerItem = (parseFloat(singleUnit) * (parseInt(item.quantity) * parseFloat(item.price))).toFixed(2);
|
|
1124
|
-
let discountPerItem = (parseFloat(singleUnit) * parseFloat(item.price)).toFixed(2);
|
|
1131
|
+
let discountPerItem = (parseFloat(singleUnit) * parseFloat(item.price * item.quantity)).toFixed(2);
|
|
1125
1132
|
totalApplied = (parseFloat(totalApplied) + parseFloat(discountPerItem)).toFixed(2);
|
|
1126
1133
|
item.default_combo_discount = parseFloat(discountPerItem).toFixed(2);
|
|
1127
1134
|
if (index == packageItems.length - 1) {
|
|
1128
|
-
|
|
1129
1135
|
let remaningOfferAmount = (parseFloat(totalDiscount) - parseFloat(totalApplied)).toFixed(2);
|
|
1130
1136
|
for (const updateItem of packageItems) {
|
|
1131
1137
|
let updateDisc = (parseFloat(updateItem.default_combo_discount) + parseFloat(remaningOfferAmount)).toFixed(2);
|
package/package.json
CHANGED