@infrab4a/connect-angular 3.8.2 → 3.8.3
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.
|
@@ -819,11 +819,13 @@
|
|
|
819
819
|
.updateCheckoutLineItems(checkoutLoaded)
|
|
820
820
|
.pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
|
|
821
821
|
})); };
|
|
822
|
-
this.generateCartObject = function (items) { return items
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
822
|
+
this.generateCartObject = function (items) { return items
|
|
823
|
+
? items.reduce(function (cart, item) {
|
|
824
|
+
var _h;
|
|
825
|
+
var _a;
|
|
826
|
+
return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i3.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })), _h)));
|
|
827
|
+
}, {})
|
|
828
|
+
: []; };
|
|
827
829
|
this.buildLineItem = function (_h) {
|
|
828
830
|
var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
|
|
829
831
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -1005,7 +1007,7 @@
|
|
|
1005
1007
|
return __generator(this, function (_o) {
|
|
1006
1008
|
switch (_o.label) {
|
|
1007
1009
|
case 0:
|
|
1008
|
-
notGiftItems = checkout.lineItems.filter(function (item) { return !item.isGift; });
|
|
1010
|
+
notGiftItems = checkout.lineItems ? checkout.lineItems.filter(function (item) { return !item.isGift; }) : [];
|
|
1009
1011
|
if (!notGiftItems.length)
|
|
1010
1012
|
return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: [] })];
|
|
1011
1013
|
cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
|