foodbot-cart-calculations 1.0.20 → 1.0.21
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.
|
@@ -31,7 +31,6 @@ function offerCalculation(carts, offer) {
|
|
|
31
31
|
if (offer && offer.offer_discount_type && offer.offer_discount_type == 'buy_x_get_y') {
|
|
32
32
|
getOfferDetails(carts, offer).then(res => {
|
|
33
33
|
carts = res
|
|
34
|
-
console.log("res",res)
|
|
35
34
|
if (offer && offer.oo_offer_type == 'percentage' && offer.discount_roundoff && offer.discount_roundoff == 1) {
|
|
36
35
|
|
|
37
36
|
// offer.oo_offer_types = JSON.parse(JSON.stringify(offer.oo_offer_type))
|
|
@@ -439,7 +438,9 @@ function getOfferDetails(carts, offer = []) {
|
|
|
439
438
|
const offerBuyProducts = offer.offer_products.offer_buy_products.map(Number);
|
|
440
439
|
const offerGetProducts = offer.offer_products.offer_get_products.map(Number);
|
|
441
440
|
addItemQuantity(carts.item_details, offer).then((data) => {
|
|
442
|
-
|
|
441
|
+
|
|
442
|
+
const descending = data.sort((a, b) => (parseInt(b.amount) < parseInt(a.amount)) ? -1 : 1);
|
|
443
|
+
// console.log("data where we sort based on amount",JSON.stringify(descending))
|
|
443
444
|
let total = 0
|
|
444
445
|
let buyItemAmount=0;
|
|
445
446
|
let buyItemss =[]
|
|
@@ -504,6 +505,7 @@ function getBuyxGetYOnCondition(descending, cartData, offer,total,buyItemAmount,
|
|
|
504
505
|
|
|
505
506
|
if (offer.oo_offer_type === "percentage") {
|
|
506
507
|
let itemTotalDiscount = 0;
|
|
508
|
+
|
|
507
509
|
itemAmount = (parseFloat(desc[i].item.item_price) * parseFloat(offer.oo_offer_value)) / 100;
|
|
508
510
|
buyItemAmount = itemAmount
|
|
509
511
|
itemTotalDiscount += itemAmount;
|
package/package.json
CHANGED