foodbot-cart-calculations 1.0.17 → 1.0.19
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.
- package/functions/promotionCalculation.js +159 -217
- package/package.json +1 -1
|
@@ -31,12 +31,13 @@ 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)
|
|
34
35
|
if (offer && offer.oo_offer_type == 'percentage' && offer.discount_roundoff && offer.discount_roundoff == 1) {
|
|
35
36
|
|
|
36
37
|
// offer.oo_offer_types = JSON.parse(JSON.stringify(offer.oo_offer_type))
|
|
37
38
|
// offer.oo_offer_values = JSON.parse(JSON.stringify(offer.oo_offer_value))
|
|
38
39
|
offer.oo_offer_type = 'absolute'
|
|
39
|
-
offer.oo_offer_value = Math.round(carts.discount)
|
|
40
|
+
offer.oo_offer_value = (carts && carts.discount)?Math.round(carts.discount):0
|
|
40
41
|
getOfferDetails(carts, offer).then(res => {
|
|
41
42
|
resolve(res)
|
|
42
43
|
}).catch(error=>{
|
|
@@ -452,7 +453,7 @@ function getOfferDetails(carts, offer = []) {
|
|
|
452
453
|
reject(error);
|
|
453
454
|
})
|
|
454
455
|
} else {
|
|
455
|
-
resolve(
|
|
456
|
+
resolve(carts);
|
|
456
457
|
}
|
|
457
458
|
} catch (error) {
|
|
458
459
|
reject(error)
|
|
@@ -460,234 +461,169 @@ function getOfferDetails(carts, offer = []) {
|
|
|
460
461
|
})
|
|
461
462
|
};
|
|
462
463
|
|
|
463
|
-
function getBuyxGetYOnCondition(descending, cartData, offer,total,buyItemAmount,buyItemss) {
|
|
464
|
-
return new Promise(function (resolve, reject) {
|
|
465
|
-
|
|
466
|
-
try {
|
|
467
|
-
let carts = cartData.item_details
|
|
468
|
-
var desc = JSON.parse(JSON.stringify(descending));
|
|
469
|
-
var desc1 = JSON.parse(JSON.stringify(descending));
|
|
470
|
-
var amount = 0;
|
|
471
|
-
var buyArray = [];
|
|
472
|
-
var getArray = [];
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
if (!cartData.totalDiscount)
|
|
476
|
-
cartData.totalDiscount = 0
|
|
477
|
-
|
|
478
|
-
var buyItems = desc.filter((e) => {
|
|
479
|
-
if (offer.offer_products.offer_buy_products.includes(parseInt(e.item_id))) {
|
|
480
|
-
return e.item_id;
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
let totalCount = parseInt(offer.offer_products.get_item_count) + parseInt(offer.offer_products.buy_item_count);
|
|
487
|
-
|
|
488
|
-
if (buyItems && parseInt(buyItems.length) >= parseInt(offer.offer_products.buy_item_count) && desc.length > 1 && descending.length >= totalCount) {
|
|
489
|
-
var buyCount = 0;
|
|
490
|
-
var getCount = 0;
|
|
491
|
-
|
|
492
|
-
for (var i = 0, ii = desc.length; i < ii; i++) {
|
|
493
|
-
let itemAmount = 0;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (desc[i] && desc[i].get && getCount < offer.offer_products.get_item_count && getCount != offer.offer_products.get_item_count && desc[i].buy && buyCount < offer.offer_products.buy_item_count && buyCount != offer.offer_products.buy_item_count
|
|
497
|
-
) {
|
|
498
|
-
var amt = 0;
|
|
499
|
-
let amtWithModi = 0;
|
|
500
|
-
getArray.push(desc[i].item_id);
|
|
501
|
-
|
|
502
|
-
buyCount++;
|
|
503
|
-
desc1[i].remove = true;
|
|
504
|
-
buyArray.push(desc[i].item_id);
|
|
505
|
-
var itemIndex = -1;
|
|
506
|
-
|
|
507
|
-
if (desc[i]) itemIndex = carts.findIndex((obj) => obj.item_id == desc[i].item.item_id);
|
|
508
|
-
|
|
509
|
-
if (offer.oo_offer_type == "percentage") {
|
|
510
|
-
|
|
511
|
-
console.log('desc[i].item.item_pricedesc[i].item.item_price', desc[i].item.item_price)
|
|
512
|
-
|
|
513
|
-
let itemTotalDiscount = 0;
|
|
514
|
-
itemAmount =
|
|
515
|
-
(parseFloat(desc[i].item.item_price)) *
|
|
516
|
-
parseFloat(offer.oo_offer_value) /
|
|
517
|
-
100;
|
|
518
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(itemAmount);
|
|
519
|
-
amt = parseFloat(amt) + parseFloat(itemAmount);
|
|
520
|
-
amt = parseFloat(amt);
|
|
521
|
-
amtWithModi = amt;
|
|
522
|
-
|
|
523
|
-
let modiItemAmount = 0;
|
|
524
|
-
cartData.totalDiscount = parseFloat(cartData.totalDiscount) + parseFloat(amt)
|
|
525
|
-
carts[itemIndex].promotion_discount_modifier = parseFloat(
|
|
526
|
-
parseFloat(carts[itemIndex].promotion_discount_modifier) +
|
|
527
|
-
parseFloat(amt)
|
|
528
|
-
).toFixed(2);
|
|
529
|
-
|
|
530
|
-
if (desc[i].item.item_modifiers.length > 0 && offer.offer_products.order_modifiercost_use == 1) {
|
|
531
|
-
let modiCount = 0;
|
|
532
|
-
|
|
533
|
-
desc[i].item.item_modifiers.forEach((modi, mIndex) => {
|
|
534
|
-
modiItemAmount =
|
|
535
|
-
(((parseFloat(modi.modifier_item_price) * parseFloat(modi.quantity))) *
|
|
536
|
-
parseFloat(offer.oo_offer_value)) /
|
|
537
|
-
100;
|
|
538
|
-
|
|
539
|
-
if (carts[itemIndex].item_modifiers[mIndex]) {
|
|
540
|
-
carts[itemIndex].item_modifiers[mIndex].promotion_discount = parseFloat(
|
|
541
|
-
modiItemAmount
|
|
542
|
-
).toFixed(2);
|
|
543
|
-
|
|
544
|
-
carts[itemIndex].item_modifiers[mIndex].redeem_promotion_id = offer.offer_id;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
cartData.totalDiscount = parseFloat(cartData.totalDiscount) + parseFloat(modiItemAmount)
|
|
548
|
-
carts[itemIndex].promotion_discount_modifier = parseFloat(
|
|
549
|
-
parseFloat(carts[itemIndex].promotion_discount_modifier) +
|
|
550
|
-
parseFloat(modiItemAmount)
|
|
551
|
-
).toFixed(2);
|
|
552
|
-
|
|
553
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount);
|
|
554
|
-
amtWithModi = parseFloat(amtWithModi) + parseFloat(modiItemAmount);
|
|
555
|
-
amtWithModi = parseFloat(amtWithModi);
|
|
556
|
-
amt = parseFloat(amt) + parseFloat(amtWithModi);
|
|
557
|
-
|
|
558
|
-
var modiIndex = carts[itemIndex].item_modifiers.findIndex((obj) => {
|
|
559
|
-
return obj.modifier_item_id == modi.modifier_item_id;
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
// if (carts[itemIndex].item_modifiers[modiIndex]) {
|
|
563
|
-
// carts[itemIndex].item_modifiers[modiIndex].promotion_discount = parseFloat(
|
|
564
|
-
// modiItemAmount
|
|
565
|
-
// ).toFixed(2);
|
|
566
|
-
// carts[itemIndex].item_modifiers[modiIndex].redeem_promotion_id = offer.offer_id;
|
|
567
|
-
// }
|
|
568
|
-
|
|
569
|
-
// modiCount++;
|
|
570
|
-
});
|
|
571
|
-
} else {
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
carts[itemIndex].promotion_discount = parseFloat(
|
|
575
|
-
parseFloat(carts[itemIndex].promotion_discount) + parseFloat(itemAmount)
|
|
576
|
-
).toFixed(2);
|
|
577
|
-
|
|
578
|
-
// carts[itemIndex].promotion_discount_modifier = parseFloat(
|
|
579
|
-
// parseFloat(carts[itemIndex].promotion_discount_modifier) +
|
|
580
|
-
// parseFloat(itemTotalDiscount)
|
|
581
|
-
// ).toFixed(2);
|
|
582
|
-
carts[itemIndex].redeem_promotion_id = offer.offer_id;
|
|
583
|
-
} else {
|
|
584
|
-
buyItemAmount = buyItemAmount + desc[i].amount;
|
|
585
|
-
desc[i].item.indexss = i;
|
|
586
|
-
buyItemss.push(desc[i].item);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
if (parseInt(amt) != 0) {
|
|
590
|
-
let amtModiTotal = amt;
|
|
591
|
-
// carts[itemIndex].promotion_discount_modifier = amtModiTotal;
|
|
592
|
-
// carts[itemIndex].promotion_discount = (
|
|
593
|
-
// parseFloat(carts[itemIndex].promotion_discount) + parseFloat(itemAmount)
|
|
594
|
-
// ).toFixed(2);
|
|
595
|
-
total = total + amtWithModi;
|
|
596
|
-
|
|
597
|
-
// console.log('amount modifffffffffffffff', amtModiTotal)
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
carts[itemIndex].redeem_promotion_id = offer.offer_id;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
getCount++;
|
|
605
|
-
desc1[i].remove = true;
|
|
606
|
-
desc1[i + 1].remove = true;
|
|
607
|
-
}
|
|
608
464
|
|
|
609
|
-
if (
|
|
610
|
-
getCount == offer.offer_products.get_item_count &&
|
|
611
|
-
buyCount == offer.offer_products.buy_item_count
|
|
612
|
-
) {
|
|
613
|
-
total = parseFloat(total) + parseFloat(amount);
|
|
614
|
-
// cartData.totalDiscount = parseFloat(cartData.totalDiscount) + parseFloat(amount)
|
|
615
|
-
|
|
616
|
-
if (offer.offer_products.order_multi_use == 1) {
|
|
617
|
-
var filterItem = desc1.filter((e) => {
|
|
618
|
-
if (!e.remove) {
|
|
619
|
-
return e.item_id;
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
465
|
|
|
623
466
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
reject(error);
|
|
638
|
-
})
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
641
|
-
cartData.discount = cartData.totalDiscount
|
|
642
|
-
resolve(cartData);
|
|
643
|
-
}
|
|
467
|
+
function getBuyxGetYOnCondition(descending, cartData, offer,total,buyItemAmount,buyItemss) {
|
|
468
|
+
return new Promise((resolve, reject) => {
|
|
469
|
+
let carts = cartData.item_details;
|
|
470
|
+
const desc = JSON.parse(JSON.stringify(descending));
|
|
471
|
+
const desc1 = JSON.parse(JSON.stringify(descending));
|
|
472
|
+
let amount = 0;
|
|
473
|
+
const buyArray = [];
|
|
474
|
+
const getArray = [];
|
|
475
|
+
const buyItems = desc.filter(e => {
|
|
476
|
+
if (offer.offer_products.offer_buy_products.some(item => item == e.item_id)) {
|
|
477
|
+
return e.item_id;
|
|
478
|
+
}
|
|
479
|
+
});
|
|
644
480
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
const totalCount = parseInt(offer.offer_products.get_item_count) + parseInt(offer.offer_products.buy_item_count);
|
|
484
|
+
if (buyItems && parseInt(buyItems.length) >= parseInt(offer.offer_products.buy_item_count) && desc.length > 1 && descending.length >= totalCount) {
|
|
485
|
+
let buyCount = 0;
|
|
486
|
+
let getCount = 0;
|
|
487
|
+
for (let i = 0; i < desc.length; i++) {
|
|
488
|
+
let itemAmount = 0;
|
|
489
|
+
|
|
490
|
+
if (desc[i].buy && buyCount < offer.offer_products.buy_item_count && buyCount != offer.offer_products.buy_item_count) {
|
|
491
|
+
buyCount++;
|
|
492
|
+
desc1[i].remove = true;
|
|
493
|
+
// buyItemss.push(desc[i].item_id);
|
|
494
|
+
} else if (desc[i] && desc[i].get && getCount < offer.offer_products.get_item_count && getCount != offer.offer_products.get_item_count) {
|
|
495
|
+
let amt = 0;
|
|
496
|
+
let amtWithModi = 0;
|
|
497
|
+
// getArray.push(desc[i].item_id);
|
|
498
|
+
|
|
499
|
+
let itemIndex = -1;
|
|
500
|
+
if (desc[i]) itemIndex = carts.findIndex(obj => obj.item_id == desc[i].item.item_id && !obj.discount_status);
|
|
501
|
+
if (itemIndex == -1) itemIndex = carts.findIndex(obj => obj.item_id == desc[i].item.item_id);
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
if (offer.oo_offer_type === "percentage") {
|
|
506
|
+
let itemTotalDiscount = 0;
|
|
507
|
+
itemAmount = (parseFloat(desc[i].item.item_price) * parseFloat(offer.oo_offer_value)) / 100;
|
|
508
|
+
|
|
509
|
+
itemTotalDiscount += itemAmount;
|
|
510
|
+
amt += itemAmount;
|
|
511
|
+
amtWithModi = amt;
|
|
512
|
+
let modiItemAmount = 0;
|
|
513
|
+
|
|
514
|
+
if (desc[i].item.item_modifiers.length > 0 && offer.offer_products.order_modifiercost_use == 1) {
|
|
515
|
+
let modiCount = 0;
|
|
516
|
+
desc[i].item.item_modifiers.forEach(modi => {
|
|
517
|
+
modiItemAmount = ((parseFloat(modi.modifier_item_price) * parseFloat(modi.quantity)) * parseFloat(offer.oo_offer_value)) / 100;
|
|
518
|
+
itemTotalDiscount += modiItemAmount;
|
|
519
|
+
amtWithModi += modiItemAmount;
|
|
520
|
+
amt += amtWithModi;
|
|
521
|
+
|
|
522
|
+
const modiIndex = carts[itemIndex].item_modifiers.findIndex(obj => obj.modifier_item_id == modi.modifier_item_id);
|
|
523
|
+
if (carts[itemIndex].item_modifiers[modiIndex]) {
|
|
524
|
+
carts[itemIndex].item_modifiers[modiIndex].promotion_discount = parseFloat(modiItemAmount).toFixed(2);
|
|
525
|
+
carts[itemIndex].item_modifiers[modiIndex].redeem_promotion_id = offer.offer_id;
|
|
526
|
+
}
|
|
527
|
+
modiCount++;
|
|
528
|
+
});
|
|
529
|
+
}
|
|
653
530
|
} else {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
})
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
cartData.discount = cartData.totalDiscount
|
|
664
|
-
resolve(cartData);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
|
|
531
|
+
// Handle absolute discount type
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
buyItemAmount = buyItemAmount + desc[i].amount;
|
|
535
|
+
desc[i].item.indexss = i;
|
|
536
|
+
buyItemss.push(desc[i].item);
|
|
668
537
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
538
|
+
|
|
539
|
+
if (parseInt(amt) != 0) {
|
|
540
|
+
const amtModiTotal = (offer.offer_products.order_modifiercost_use == 1)
|
|
541
|
+
? (parseFloat(carts[itemIndex].promotion_discount_modifier) + parseFloat(amtWithModi)).toFixed(2)
|
|
542
|
+
: (parseFloat(carts[itemIndex].promotion_discount) + parseFloat(amt)).toFixed(2);
|
|
543
|
+
|
|
544
|
+
carts[itemIndex].promotion_discount_modifier = amtModiTotal;
|
|
545
|
+
carts[itemIndex].promotion_discount = (parseFloat(carts[itemIndex].promotion_discount) + parseFloat(buyItemAmount)).toFixed(2);
|
|
546
|
+
carts[itemIndex].discount_status = true;
|
|
547
|
+
total = total + amtWithModi;
|
|
548
|
+
carts[itemIndex].redeem_promotion_id = offer.offer_id;
|
|
549
|
+
|
|
550
|
+
}
|
|
551
|
+
getCount++;
|
|
552
|
+
desc1[i].remove = true;
|
|
553
|
+
cartData.totalDiscount = total;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
if (getCount == offer.offer_products.get_item_count && buyCount == offer.offer_products.buy_item_count) {
|
|
559
|
+
|
|
560
|
+
total = parseFloat(total) + parseFloat(amount);
|
|
561
|
+
if (offer.offer_products.order_multi_use == 1) {
|
|
562
|
+
const filterItem = desc1.filter(e => !e.remove);
|
|
563
|
+
|
|
564
|
+
cartData.item_details = carts
|
|
565
|
+
getBuyxGetYOnCondition(filterItem, cartData, offer,total,buyItemAmount,buyItemss).then((data) => {
|
|
566
|
+
resolve(data)
|
|
567
|
+
}).catch(error => {
|
|
568
|
+
reject(error);
|
|
569
|
+
})
|
|
570
|
+
break;
|
|
571
|
+
} else {
|
|
572
|
+
if (offer.oo_offer_type === 'absolute') {
|
|
573
|
+
cartData.item_details = carts
|
|
574
|
+
getAbsoluteDiscount(cartData, offer, buyItemss, buyItemAmount,total).then((data) => {
|
|
575
|
+
resolve(data);
|
|
576
|
+
}).catch(error => {
|
|
577
|
+
reject(error);
|
|
578
|
+
})
|
|
579
|
+
}else{
|
|
580
|
+
cartData.discount = cartData.totalDiscount
|
|
581
|
+
resolve(cartData);
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
}else{
|
|
586
|
+
|
|
587
|
+
if(i == desc.length -1){
|
|
588
|
+
|
|
589
|
+
cartData.discount = cartData.totalDiscount?cartData.totalDiscount:0;
|
|
590
|
+
resolve(cartData);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
} else {
|
|
596
|
+
if (offer.oo_offer_type === 'absolute') {
|
|
597
|
+
|
|
598
|
+
cartData.item_details = carts
|
|
599
|
+
getAbsoluteDiscount(cartData, offer, buyItemss, buyItemAmount,total).then((data) => {
|
|
600
|
+
resolve(data);
|
|
601
|
+
}).catch(error => {
|
|
602
|
+
reject(error);
|
|
603
|
+
})
|
|
604
|
+
}else{
|
|
605
|
+
cartData.discount = cartData.totalDiscount
|
|
606
|
+
resolve(cartData);
|
|
678
607
|
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// setTimeout(() => {
|
|
611
|
+
// resolve(0);
|
|
612
|
+
// }, 20);
|
|
679
613
|
});
|
|
680
|
-
}
|
|
681
|
-
|
|
614
|
+
}
|
|
615
|
+
|
|
682
616
|
function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total) {
|
|
683
617
|
return new Promise(function (resolve, reject) {
|
|
684
618
|
try {
|
|
619
|
+
console.log("ooooooooooooooo",JSON.parse(JSON.stringify(offer)))
|
|
685
620
|
let offerAmount = offer.oo_offer_value;
|
|
686
621
|
let singlePriceDiscount = offerAmount / buyItemAmount;
|
|
687
622
|
singlePriceDiscount = parseFloat(singlePriceDiscount).toFixed(6);
|
|
688
623
|
let remaningOfferAmount = offer.oo_offer_value;
|
|
689
624
|
let count = 0;
|
|
690
|
-
let carts = cartObject.item_details
|
|
625
|
+
let carts = cartObject.item_details;
|
|
626
|
+
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",buyItemss,total)
|
|
691
627
|
if(buyItemss && buyItemss.length>0){
|
|
692
628
|
buyItemss.forEach((element, buyIndex) => {
|
|
693
629
|
let itemAmount = 0;
|
|
@@ -699,8 +635,10 @@ function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total)
|
|
|
699
635
|
if (itemIndex == -1) itemIndex = carts.findIndex((obj) => {
|
|
700
636
|
return obj.item_id == element.item_id;
|
|
701
637
|
});
|
|
638
|
+
|
|
639
|
+
console.log("carts index",carts,itemIndex)
|
|
702
640
|
|
|
703
|
-
if (!carts[itemIndex].promotion_discount_modifier) carts[itemIndex].promotion_discount_modifier = 0;
|
|
641
|
+
if ( !carts[itemIndex].promotion_discount_modifier) carts[itemIndex].promotion_discount_modifier = 0;
|
|
704
642
|
|
|
705
643
|
if (element.item_modifiers && element.item_modifiers.length > 0 && offer.offer_products.order_modifiercost_use == 1) {
|
|
706
644
|
let modiCount = 0;
|
|
@@ -745,6 +683,7 @@ function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total)
|
|
|
745
683
|
carts[itemIndex].discount_applied = true;
|
|
746
684
|
|
|
747
685
|
if (buyItemss[buyItemss.length - 1].item_id == element.item_id) {
|
|
686
|
+
console.log("innnn ifffffffffffff",element.item_price,remaningOfferAmount)
|
|
748
687
|
|
|
749
688
|
itemAmount = (element.item_price < remaningOfferAmount) ? element.item_price : parseFloat(remaningOfferAmount).toFixed(2);
|
|
750
689
|
} else {
|
|
@@ -752,6 +691,7 @@ function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total)
|
|
|
752
691
|
}
|
|
753
692
|
|
|
754
693
|
itemAmount = parseFloat(itemAmount);
|
|
694
|
+
console.log("iiiiiiiiii",itemAmount)
|
|
755
695
|
total = parseFloat(total) + parseFloat(itemAmount);
|
|
756
696
|
total = parseFloat(total).toFixed(2);
|
|
757
697
|
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(itemAmount);
|
|
@@ -762,10 +702,10 @@ function getAbsoluteDiscount(cartObject, offer, buyItemss, buyItemAmount,total)
|
|
|
762
702
|
carts[itemIndex].redeem_promotion_id = offer.offer_id;
|
|
763
703
|
|
|
764
704
|
if (count == buyItemss.length) {
|
|
705
|
+
console.log("ttttttttttttttt",total)
|
|
765
706
|
cartObject.item_details = carts
|
|
766
707
|
cartObject.discount = total
|
|
767
|
-
|
|
768
|
-
|
|
708
|
+
|
|
769
709
|
resolve(cartObject);
|
|
770
710
|
}
|
|
771
711
|
});
|
|
@@ -783,6 +723,8 @@ function addItemQuantity(items, offer) {
|
|
|
783
723
|
try {
|
|
784
724
|
var finalItems = [];
|
|
785
725
|
var count = 0;
|
|
726
|
+
offer.offer_products.offer_buy_products=offer.offer_products.offer_buy_products.map(item => parseInt(item, 10));
|
|
727
|
+
offer.offer_products.offer_get_products=offer.offer_products.offer_get_products.map(item => parseInt(item, 10));
|
|
786
728
|
items.forEach(function (element) {
|
|
787
729
|
if (offer.offer_products.offer_buy_products.includes(parseInt(element.item_id)) || offer.offer_products.offer_get_products.includes(parseInt(element.item_id))) {
|
|
788
730
|
for (var i = 1; i <= element.quantity; i++) {
|
package/package.json
CHANGED