simpo-component-library 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/lib/ecommerce/sections/cart/cart.component.mjs +39 -9
- package/fesm2022/simpo-component-library.mjs +38 -8
- package/fesm2022/simpo-component-library.mjs.map +1 -1
- package/lib/ecommerce/sections/cart/cart.component.d.ts +1 -0
- package/package.json +1 -1
- package/simpo-component-library-1.9.3.tgz +0 -0
- package/simpo-component-library-1.9.2.tgz +0 -0
@@ -4592,13 +4592,12 @@ class CartComponent extends BaseSection {
|
|
4592
4592
|
this.getIndexDBData();
|
4593
4593
|
}
|
4594
4594
|
});
|
4595
|
-
if (this.storageService.getUser()) {
|
4596
|
-
|
4597
|
-
}
|
4598
|
-
|
4599
|
-
|
4600
|
-
|
4601
|
-
}
|
4595
|
+
// if (this.storageService.getUser()) {
|
4596
|
+
// this.updateUserCart();
|
4597
|
+
// } else {
|
4598
|
+
// this.getIndexDBData();
|
4599
|
+
// console.log(this.responseData);
|
4600
|
+
// }
|
4602
4601
|
console.log(this.responseData);
|
4603
4602
|
this.styles = this.data?.styles;
|
4604
4603
|
}
|
@@ -4620,7 +4619,8 @@ class CartComponent extends BaseSection {
|
|
4620
4619
|
this.cartInfo["cartId"] = response.data?.[0]?.cartId;
|
4621
4620
|
this.getCouponList();
|
4622
4621
|
if (response.data?.[0]?.orderedItems?.length > 0) {
|
4623
|
-
this.
|
4622
|
+
this.mergeOrderItems(tempUserCart);
|
4623
|
+
this.storageService.addAllProductsToCart(this.cartInfo.orderedItems).oncomplete = () => {
|
4624
4624
|
this.storageService.getUserCart().then((cartResponse) => {
|
4625
4625
|
cartResponse.onsuccess = (cartData) => {
|
4626
4626
|
if (!(localStorage.getItem("couponId") == "undefined" || localStorage.getItem("couponId") == "null"))
|
@@ -4686,6 +4686,34 @@ class CartComponent extends BaseSection {
|
|
4686
4686
|
}
|
4687
4687
|
});
|
4688
4688
|
}
|
4689
|
+
// updateUserCart2() {
|
4690
|
+
// const deliveryOption = JSON.parse(localStorage.getItem("deliveryOptions") ?? "{}");
|
4691
|
+
// this.userDetails = this.storageService.getUser() as User;
|
4692
|
+
// this.cartInfo.userDetails = {
|
4693
|
+
// "userId": this.userDetails?.userId,
|
4694
|
+
// "userName": this.userDetails?.contact.name,
|
4695
|
+
// "mobile": this.userDetails?.contact.mobile,
|
4696
|
+
// "email": this.userDetails?.contact.email,
|
4697
|
+
// }
|
4698
|
+
// this.restService.getUserItems(this.userDetails.userId, "CART").subscribe((response: any) => {
|
4699
|
+
// const tempUserCart = response?.data?.[0]?.orderedItems ?? [];
|
4700
|
+
// this.mergeOrderItems(tempUserCart);
|
4701
|
+
// })
|
4702
|
+
// }
|
4703
|
+
mergeOrderItems(syncedItems) {
|
4704
|
+
for (let product of syncedItems) {
|
4705
|
+
let itemFound = false;
|
4706
|
+
for (let cartItem of this.cartInfo.orderedItems) {
|
4707
|
+
if (cartItem.varientId === product.varientId) {
|
4708
|
+
itemFound = true;
|
4709
|
+
cartItem.quantity += product.quantity;
|
4710
|
+
}
|
4711
|
+
}
|
4712
|
+
if (!itemFound) {
|
4713
|
+
this.cartInfo.orderedItems.push(product);
|
4714
|
+
}
|
4715
|
+
}
|
4716
|
+
}
|
4689
4717
|
getCouponList() {
|
4690
4718
|
if (!this.cartInfo.cartId && !(localStorage.getItem("cartId") == "undefined" || localStorage.getItem("cartId") == "null"))
|
4691
4719
|
this.cartInfo.cartId = localStorage.getItem("cartId");
|
@@ -4740,6 +4768,8 @@ class CartComponent extends BaseSection {
|
|
4740
4768
|
console.log(this.cartInfo.billdetails.totalNetValue, this.cartInfo.billdetails.totalTax, this.cartInfo.billdetails.deliveryCharges);
|
4741
4769
|
this.cartInfo.totalAmount = this.cartInfo.billdetails.totalNetValue + this.getTaxAmount() + this.cartInfo.billdetails.deliveryCharges;
|
4742
4770
|
this.cartInfo.orderedItems = this.USER_CART_ITEMS;
|
4771
|
+
if (this.storageService.getUser())
|
4772
|
+
this.updateUserCart();
|
4743
4773
|
this.responseData = this.cartInfo;
|
4744
4774
|
};
|
4745
4775
|
});
|