@infrab4a/connect-angular 4.8.2 → 4.9.1-beta.1

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.
@@ -1322,11 +1322,13 @@ class CartService {
1322
1322
  this.buy2WinRepository = buy2WinRepository;
1323
1323
  this.cartSubject = new Subject();
1324
1324
  this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1325
+ console.log('updateLineItemInCart', lineItem);
1325
1326
  const items = [];
1326
1327
  const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1327
1328
  if (index > -1) {
1328
1329
  checkoutLoaded.lineItems[index].quantity += quantity;
1329
1330
  checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1331
+ console.log('if index', checkoutLoaded.lineItems[index]);
1330
1332
  }
1331
1333
  else
1332
1334
  checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
@@ -1347,14 +1349,16 @@ class CartService {
1347
1349
  if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
1348
1350
  throw new Error('Desculpe! Temos apenas ' + product.stock?.quantity + ' em estoque.');
1349
1351
  const image = item.image || item.images?.shift();
1350
- const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
1352
+ const { id, name, EAN, slug, weight, sku, type } = item;
1351
1353
  const isGift = item.isGift || null;
1352
1354
  const pricePaid = this.getProductPrice({
1353
- product: item,
1355
+ product: LineItem.toInstance(product),
1354
1356
  shop: checkout.shop || this.defaultShop,
1355
1357
  isSubscriber: checkout.user?.isSubscriber,
1356
1358
  });
1359
+ console.log('pricePaid', pricePaid);
1357
1360
  RoundProductPricesHelper.roundProductPrices(item);
1361
+ RoundProductPricesHelper.roundProductPrices(product);
1358
1362
  return {
1359
1363
  checkout,
1360
1364
  lineItem: LineItem.toInstance({
@@ -1364,8 +1368,8 @@ class CartService {
1364
1368
  brand: product.brand,
1365
1369
  slug: slug ?? product.slug,
1366
1370
  sku: sku ?? product.sku,
1367
- stock,
1368
- price: this.roundPrice(price),
1371
+ stock: product.stock,
1372
+ price: this.roundPrice(product.price),
1369
1373
  image,
1370
1374
  weight: weight ?? product.weight,
1371
1375
  quantity: (item.quantity || 0) + (quantity || 0),