@infrab4a/connect-angular 4.14.0-beta.3 → 4.14.0-beta.5
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.
|
@@ -1542,6 +1542,7 @@ class CartService {
|
|
|
1542
1542
|
getGifts() {
|
|
1543
1543
|
return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
|
|
1544
1544
|
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1545
|
+
console.log('notGiftItems', notGiftItems.map((i) => ({ name: i.name, quantity: i.quantity })));
|
|
1545
1546
|
if (!notGiftItems.length)
|
|
1546
1547
|
return { ...checkout, lineItems: [] };
|
|
1547
1548
|
const campaigns = await this.buy2WinRepository
|
|
@@ -1567,7 +1568,7 @@ class CartService {
|
|
|
1567
1568
|
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1568
1569
|
}
|
|
1569
1570
|
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1570
|
-
const filterProductsCategories =
|
|
1571
|
+
const filterProductsCategories = notGiftItems.filter((l) => {
|
|
1571
1572
|
if (!l.categories || !l.categories?.length)
|
|
1572
1573
|
return true;
|
|
1573
1574
|
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
@@ -1577,6 +1578,9 @@ class CartService {
|
|
|
1577
1578
|
const cartItensQuantityWithCategories = filterProductsCategories.reduce((a, b) => a + b.quantity, 0);
|
|
1578
1579
|
const hasMinValue = cartValuelWithCategories >= campaign.cartValueMin;
|
|
1579
1580
|
const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantityWithCategories >= campaign.cartItensQuantityMin;
|
|
1581
|
+
console.log('------------------------------');
|
|
1582
|
+
console.log('campaing WITH categories', campaign.name, campaign.cartValueMin, campaign.cartItensQuantityMin);
|
|
1583
|
+
console.log('cartValuelWithCategories', cartValuelWithCategories, 'cartItensQuantityWithCategories', cartItensQuantityWithCategories, 'hasMinValue', hasMinValue, 'hasMinQuantity', hasMinQuantity);
|
|
1580
1584
|
if (hasMinQuantity || hasMinValue)
|
|
1581
1585
|
elegibleCampaigns.push(campaign);
|
|
1582
1586
|
}
|
|
@@ -1586,11 +1590,13 @@ class CartService {
|
|
|
1586
1590
|
const cartItensQuantity = notGiftItems.reduce((a, b) => a + b.quantity, 0);
|
|
1587
1591
|
const hasMinValue = campaign.cartValue && campaign.cartValue > 0 && campaign.cartValue <= cartTotal;
|
|
1588
1592
|
const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantity >= campaign.cartItensQuantityMin;
|
|
1593
|
+
console.log('------------------------------');
|
|
1594
|
+
console.log('campaing WITHOUT categories', campaign.name, campaign.cartValue, campaign.cartItensQuantityMin);
|
|
1595
|
+
console.log('cartTotal', cartTotal, 'cartItensQuantity', cartItensQuantity, 'hasMinValue', hasMinValue, 'hasMinQuantity', hasMinQuantity);
|
|
1589
1596
|
if (hasMinQuantity || hasMinValue)
|
|
1590
1597
|
elegibleCampaigns.push(campaign);
|
|
1591
1598
|
}
|
|
1592
1599
|
}
|
|
1593
|
-
console.log('lineItens', notGiftItems.map((l) => [l.name, l.quantity]));
|
|
1594
1600
|
console.log('elegibleCampaigns', elegibleCampaigns.map((c) => c.name));
|
|
1595
1601
|
if (!elegibleCampaigns.length)
|
|
1596
1602
|
return { ...checkout, lineItems: notGiftItems };
|