simpo-component-library 1.9.5 → 1.9.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -4620,40 +4620,41 @@ class CartComponent extends BaseSection {
4620
4620
  this.getCouponList();
4621
4621
  if (response.data?.[0]?.orderedItems?.length > 0) {
4622
4622
  this.mergeOrderItems(tempUserCart);
4623
- this.storageService.addAllProductsToCart(this.cartInfo.orderedItems).oncomplete = () => {
4624
- this.storageService.getUserCart().then((cartResponse) => {
4625
- cartResponse.onsuccess = (cartData) => {
4626
- if (!(localStorage.getItem("couponId") == "undefined" || localStorage.getItem("couponId") == "null"))
4627
- this.cartInfo.billdetails.couponId = localStorage.getItem("couponId");
4628
- if (!(localStorage.getItem("couponCode") == "undefined" || localStorage.getItem("couponCode") == "null"))
4629
- this.cartInfo.billdetails.couponCode = localStorage.getItem("couponCode");
4630
- const restResponse = this.restService.addItemToDB(this.cartInfo).toPromise();
4631
- restResponse.then((response) => {
4632
- this.cartInfo.billdetails.totalGrossValue = 0;
4633
- this.cartInfo.billdetails.totalTax = 0;
4634
- this.cartInfo.billdetails.deliveryCharges = 0;
4635
- this.cartInfo.billdetails.totalNetValue = 0;
4636
- this.cartInfo.totalAmount = 0;
4637
- this.USER_CART_ITEMS = cartData.target.result;
4638
- this.USER_CART_ITEMS.forEach((item) => {
4639
- this.cartInfo.billdetails.totalGrossValue += (item.discountedPrice * (item.quantity ?? 1));
4640
- this.cartInfo.billdetails.totalTax += (item.quantity * (item.itemTax ?? 0));
4641
- });
4642
- this.cartInfo.billdetails.deliveryCharges = (deliveryOption?.minOrderAmount > this.cartInfo.billdetails.totalGrossValue) ? 0 : (deliveryOption?.deliveryCharges ?? 0);
4643
- this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue;
4644
- this.cartInfo.orderedItems = this.USER_CART_ITEMS;
4645
- this.cartInfo.billdetails.discountAmount = response?.data?.billdetails?.discountAmount ?? 0;
4646
- this.cartInfo.billdetails.totalTaxAfterDiscount = response?.data?.billdetails?.totalTaxAfterDiscount ?? 0;
4647
- this.cartInfo.totalAmount = this.cartInfo.billdetails.totalNetValue + this.getTaxAmount() + this.cartInfo.billdetails.deliveryCharges;
4648
- this.responseData = this.cartInfo;
4649
- console.log(this.responseData);
4623
+ // this.storageService.addAllProductsToCart(this.cartInfo.orderedItems).oncomplete = ()=> {
4624
+ this.storageService.getUserCart().then((cartResponse) => {
4625
+ cartResponse.onsuccess = (cartData) => {
4626
+ if (!(localStorage.getItem("couponId") == "undefined" || localStorage.getItem("couponId") == "null"))
4627
+ this.cartInfo.billdetails.couponId = localStorage.getItem("couponId");
4628
+ if (!(localStorage.getItem("couponCode") == "undefined" || localStorage.getItem("couponCode") == "null"))
4629
+ this.cartInfo.billdetails.couponCode = localStorage.getItem("couponCode");
4630
+ const restResponse = this.restService.addItemToDB(this.cartInfo).toPromise();
4631
+ restResponse.then((response) => {
4632
+ this.cartInfo.billdetails.totalGrossValue = 0;
4633
+ this.cartInfo.billdetails.totalTax = 0;
4634
+ this.cartInfo.billdetails.deliveryCharges = 0;
4635
+ this.cartInfo.billdetails.totalNetValue = 0;
4636
+ this.cartInfo.totalAmount = 0;
4637
+ this.USER_CART_ITEMS = cartData.target.result;
4638
+ this.USER_CART_ITEMS.forEach((item) => {
4639
+ this.cartInfo.billdetails.totalGrossValue += (item.discountedPrice * (item.quantity ?? 1));
4640
+ this.cartInfo.billdetails.totalTax += (item.quantity * (item.itemTax ?? 0));
4650
4641
  });
4651
- };
4652
- cartResponse.onerror = (cartData) => {
4653
- this.messageService.add({ severity: 'error', summary: 'Error', detail: 'Failed to update cart details' });
4654
- };
4655
- });
4656
- };
4642
+ this.cartInfo.billdetails.deliveryCharges = (deliveryOption?.minOrderAmount > this.cartInfo.billdetails.totalGrossValue) ? 0 : (deliveryOption?.deliveryCharges ?? 0);
4643
+ this.cartInfo.billdetails.totalNetValue = this.cartInfo.billdetails.totalGrossValue;
4644
+ this.cartInfo.orderedItems = this.USER_CART_ITEMS;
4645
+ this.cartInfo.billdetails.discountAmount = response?.data?.billdetails?.discountAmount ?? 0;
4646
+ this.cartInfo.billdetails.totalTaxAfterDiscount = response?.data?.billdetails?.totalTaxAfterDiscount ?? 0;
4647
+ this.cartInfo.totalAmount = this.cartInfo.billdetails.totalNetValue + this.getTaxAmount() + this.cartInfo.billdetails.deliveryCharges;
4648
+ this.storageService.addAllProductsToCart(this.cartInfo.orderedItems);
4649
+ this.responseData = this.cartInfo;
4650
+ console.log(this.responseData);
4651
+ });
4652
+ };
4653
+ cartResponse.onerror = (cartData) => {
4654
+ this.messageService.add({ severity: 'error', summary: 'Error', detail: 'Failed to update cart details' });
4655
+ };
4656
+ });
4657
+ // }
4657
4658
  }
4658
4659
  else {
4659
4660
  this.storageService.getUserCart().then((cartResponse) => {
@@ -4706,7 +4707,7 @@ class CartComponent extends BaseSection {
4706
4707
  for (let cartItem of this.cartInfo.orderedItems) {
4707
4708
  if (cartItem.varientId === product.varientId) {
4708
4709
  itemFound = true;
4709
- cartItem.quantity = product.quantity;
4710
+ // cartItem.quantity = product.quantity;
4710
4711
  }
4711
4712
  }
4712
4713
  if (!itemFound) {