@faststore/api 2.1.66 → 2.1.78

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.
@@ -22,7 +22,7 @@ var api = require('@opentelemetry/api');
22
22
  var apiLogs = require('@opentelemetry/api-logs');
23
23
 
24
24
  var name = "@faststore/api";
25
- var version = "2.1.53";
25
+ var version = "2.1.68";
26
26
  var license = "MIT";
27
27
  var main = "dist/index.js";
28
28
  var typings = "dist/index.d.ts";
@@ -1376,14 +1376,20 @@ async function getOrderNumberFromSession(headers = {}, commerce) {
1376
1376
  return;
1377
1377
  }
1378
1378
  // Returns the regionalized orderForm
1379
- const getOrderForm = async (id, session, {
1379
+ const getOrderForm = async (id, {
1380
1380
  clients: {
1381
1381
  commerce
1382
1382
  }
1383
1383
  }) => {
1384
- const orderForm = await commerce.checkout.orderForm({
1384
+ return commerce.checkout.orderForm({
1385
1385
  id
1386
1386
  });
1387
+ };
1388
+ const updateOrderFormShippingData = async (orderForm, session, {
1389
+ clients: {
1390
+ commerce
1391
+ }
1392
+ }) => {
1387
1393
  // Stores that are not yet providing the session while validating the cart
1388
1394
  // should not be able to update the shipping data
1389
1395
  //
@@ -1466,7 +1472,7 @@ const validateCart = async (_, {
1466
1472
  const orderNumberFromSession = await getOrderNumberFromSession(headers, commerce);
1467
1473
  const orderNumber = (_ref = orderNumberFromSession != null ? orderNumberFromSession : orderNumberFromCart) != null ? _ref : '';
1468
1474
  // Step1: Get OrderForm from VTEX Commerce
1469
- const orderForm = await getOrderForm(orderNumber, session, ctx);
1475
+ const orderForm = await getOrderForm(orderNumber, ctx);
1470
1476
  // Step1.1: Checks if the orderForm id has changed. There are three cases for this:
1471
1477
  // Social Selling: the vtex_session cookie contains a new orderForm id with Social Selling data
1472
1478
  // My Orders: the customer clicks on reordering through generating a new cart and when returning to the faststore, this information needs to be returned by vtex_session cookie.
@@ -1533,6 +1539,8 @@ const validateCart = async (_, {
1533
1539
  orderItems: changes,
1534
1540
  shouldSplitItem
1535
1541
  })
1542
+ // update orderForm shippingData
1543
+ .then(form => updateOrderFormShippingData(form, session, ctx))
1536
1544
  // update orderForm etag so we know last time we touched this orderForm
1537
1545
  .then(form => setOrderFormEtag(form, commerce)).then(joinItems);
1538
1546
  // Step5: If no changes detected before/after updating orderForm, the order is validated