@infrab4a/connect-angular 4.14.0-beta.5 → 4.14.0
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.
|
@@ -1441,6 +1441,7 @@ class CartService {
|
|
|
1441
1441
|
isGift: isGift ?? null,
|
|
1442
1442
|
costPrice: isGift ? 0 : product.costPrice ?? 0,
|
|
1443
1443
|
type,
|
|
1444
|
+
label: product.label,
|
|
1444
1445
|
}),
|
|
1445
1446
|
};
|
|
1446
1447
|
};
|
|
@@ -1542,14 +1543,12 @@ class CartService {
|
|
|
1542
1543
|
getGifts() {
|
|
1543
1544
|
return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
|
|
1544
1545
|
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1545
|
-
console.log('notGiftItems', notGiftItems.map((i) => ({ name: i.name, quantity: i.quantity })));
|
|
1546
1546
|
if (!notGiftItems.length)
|
|
1547
1547
|
return { ...checkout, lineItems: [] };
|
|
1548
1548
|
const campaigns = await this.buy2WinRepository
|
|
1549
1549
|
.find({
|
|
1550
1550
|
filters: {
|
|
1551
1551
|
active: { operator: Where.EQUALS, value: true },
|
|
1552
|
-
// shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
1553
1552
|
},
|
|
1554
1553
|
})
|
|
1555
1554
|
.then((data) => data.data.filter((campaign) => campaign.shop === Shops.ALL || campaign.shop === this.defaultShop));
|
|
@@ -1576,11 +1575,8 @@ class CartService {
|
|
|
1576
1575
|
if (filterProductsCategories.length) {
|
|
1577
1576
|
const cartValuelWithCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1578
1577
|
const cartItensQuantityWithCategories = filterProductsCategories.reduce((a, b) => a + b.quantity, 0);
|
|
1579
|
-
const hasMinValue = cartValuelWithCategories >= campaign.cartValueMin;
|
|
1578
|
+
const hasMinValue = campaign.cartValueMin && cartValuelWithCategories >= campaign.cartValueMin;
|
|
1580
1579
|
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);
|
|
1584
1580
|
if (hasMinQuantity || hasMinValue)
|
|
1585
1581
|
elegibleCampaigns.push(campaign);
|
|
1586
1582
|
}
|
|
@@ -1590,14 +1586,10 @@ class CartService {
|
|
|
1590
1586
|
const cartItensQuantity = notGiftItems.reduce((a, b) => a + b.quantity, 0);
|
|
1591
1587
|
const hasMinValue = campaign.cartValue && campaign.cartValue > 0 && campaign.cartValue <= cartTotal;
|
|
1592
1588
|
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);
|
|
1596
1589
|
if (hasMinQuantity || hasMinValue)
|
|
1597
1590
|
elegibleCampaigns.push(campaign);
|
|
1598
1591
|
}
|
|
1599
1592
|
}
|
|
1600
|
-
console.log('elegibleCampaigns', elegibleCampaigns.map((c) => c.name));
|
|
1601
1593
|
if (!elegibleCampaigns.length)
|
|
1602
1594
|
return { ...checkout, lineItems: notGiftItems };
|
|
1603
1595
|
const campaingnProducts = [];
|