@nuskin/ns-shop 7.3.0-mdigi-897.7 → 7.3.0-mdigi-897.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-shop",
3
- "version": "7.3.0-mdigi-897.7",
3
+ "version": "7.3.0-mdigi-897.9",
4
4
  "description": "The description that will amaze and astound your audience when they read it",
5
5
  "main": "src/shop.js",
6
6
  "scripts": {
@@ -30,8 +30,7 @@
30
30
  "@nuskin/nuskinjquery": "2.3.1",
31
31
  "@nuskin/order-model": "3.1.3",
32
32
  "@nuskin/product-lib": "2.2.1",
33
- "@nuskin/ns-util": "4.7.0",
34
- "axios": "1.6.5",
33
+ "axios": "1.7.9",
35
34
  "decimal.js": "10.4.3",
36
35
  "jp-conversion": "0.0.7",
37
36
  "lodash": "4.17.21",
@@ -91,7 +90,7 @@
91
90
  "moment": "2.29.4",
92
91
  "json5": "2.2.3",
93
92
  "ip": "2.0.1",
94
- "axios": "1.6.8",
93
+ "axios": "1.7.9",
95
94
  "merge": "2.1.1",
96
95
  "glob-parent": "6.0.2",
97
96
  "follow-redirects": "1.15.5",
package/src/cart/cart.js CHANGED
@@ -1329,8 +1329,16 @@ export default function Cart(cartData) {
1329
1329
  const customPayloadMetadata = storage.metadata.CUSTOM_EVENT_PAYLOAD;
1330
1330
  let customPayload = storage.getItem(customPayloadMetadata);
1331
1331
  if (customPayload) {
1332
- if (customPayload.constructor === {}.constructor) {
1333
- Object.assign(json, customPayload);
1332
+ if (customPayload.catalogAddToCart) {
1333
+ delete customPayload.catalogAddToCart;
1334
+ const product = json.ecommerce.add && json.ecommerce.add.products && json.ecommerce.add.products[0];
1335
+ if (product) {
1336
+ Object.assign(product, customPayload);
1337
+ }
1338
+ } else {
1339
+ if (customPayload.constructor === {}.constructor) {
1340
+ Object.assign(json, customPayload);
1341
+ }
1334
1342
  }
1335
1343
  storage.removeItem(customPayloadMetadata);
1336
1344
  }
@@ -6,10 +6,8 @@ import {getCachedConfigField} from '@nuskin/configuration-sdk';
6
6
  import {UserService} from "@nuskin/ns-account";
7
7
  import PaymentAdapter from '../payment/PaymentAdapter';
8
8
  import pickupUtil from '../shipping/pickupUtil';
9
- import { storage } from "@nuskin/ns-util";
10
9
 
11
10
  let splitLineItems = [];
12
- const utmInfo = storage.getItem(storage.metadata.UTM_INFO);
13
11
  const addToCustomList = (customList, type, key, value) => {
14
12
  if (value) {
15
13
  let found = false;
@@ -497,14 +495,6 @@ const populateCategory = (salesOrder) => {
497
495
  } else if (util.getSponsorId()) {
498
496
  // affiliates don't use a subdomain. So if we have a sponsor and it isn't a pitch then we consider it a storefront
499
497
  salesOrder.Category = "STOREFRONT";
500
- } else if(utmInfo && utmInfo.utm_medium){
501
- if (utmInfo && utmInfo.utm_medium.includes('paidsearch')) {
502
- salesOrder.Category = 'PAIDSEARCH';
503
- } else if (utmInfo && utmInfo.utm_medium.includes('paidsocial')) {
504
- salesOrder.Category = 'PAIDAD';
505
- } else {
506
- salesOrder.Category = 'WEB';
507
- }
508
498
  } else {
509
499
  salesOrder.Category = 'WEB';
510
500
  }
@@ -1040,12 +1030,6 @@ const populateSalesOrder = (action, adr) => {
1040
1030
  if (user && user.isGuest) {
1041
1031
  addToCustomList(salesOrder.Custom, "FLAG", "GUEST", "TRUE");
1042
1032
  }
1043
- addToCustomList(salesOrder.Custom, "FLAG", "UTM_SOURCE", utmInfo ? utmInfo.utm_source : null);
1044
- addToCustomList(salesOrder.Custom, "FLAG", "UTM_MEDIUM", utmInfo ? utmInfo.utm_medium : null);
1045
- addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN", utmInfo ? utmInfo.utm_campaign : null);
1046
- addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN_ID", utmInfo ? utmInfo.utm_id : null);
1047
- addToCustomList(salesOrder.Custom, "FLAG", "UTM_CONTENT", utmInfo ? utmInfo.utm_content : null);
1048
- addToCustomList(salesOrder.Custom, "FLAG", "UTM_TERM", utmInfo ? utmInfo.utm_term : null);
1049
1033
  const microsite = getCachedConfigField('microsite');
1050
1034
  if (microsite) {
1051
1035
  salesOrder.Reason = "CUSTOM";
@@ -73,6 +73,7 @@ function productSearchAPI(deferred, options) {
73
73
  customerTypes
74
74
  description
75
75
  searchKeywords
76
+ matchingVariant
76
77
  }
77
78
  bundle {
78
79
  purchaseTypes {
@@ -170,7 +171,8 @@ function productSearchAPI(deferred, options) {
170
171
  let mappedParentProduct = parentProduct;
171
172
 
172
173
  if (!isSkuFormat(parentProduct.id) && parentProduct.variants && parentProduct.variants.length > 0) {
173
- mappedParentProduct = parentProduct.variants[0];
174
+ const matchingVariant = parentProduct.variants.find(variant => variant.matchingVariant === true);
175
+ mappedParentProduct = matchingVariant || parentProduct.variants[0];
174
176
  } else {
175
177
  mappedParentProduct.sku = parentProduct.id;
176
178
  mappedParentProduct.variants = [];
@@ -358,15 +360,27 @@ function productSearchAPI(deferred, options) {
358
360
  return orderTypes;
359
361
  }
360
362
 
361
-
362
363
  function fetchNextPage() {
363
364
  sendQuery(currentPage)
364
365
  .then(processResponse)
365
366
  .then((result) => {
366
- allProducts = allProducts.concat(result.products);
367
- if ((currentPage * options.rows) < result.totalNumFound && !options.groupByVariant) {
368
- currentPage++;
369
- fetchNextPage();
367
+ if (!result || !result.products || result.products.length === 0) {
368
+ // console.error("No products found or invalid response", result);
369
+ deferred.resolve({
370
+ products: allProducts,
371
+ totalNumFound: result.totalNumFound
372
+ });
373
+ return;
374
+ }
375
+
376
+ const remainingProducts = options.rows - allProducts.length;
377
+ const productsToAdd = result.products.slice(0, remainingProducts);
378
+
379
+ allProducts = allProducts.concat(productsToAdd);
380
+
381
+ if (allProducts.length < options.rows && (currentPage * options.rows) < result.totalNumFound && !options.groupByVariant) {
382
+ currentPage = currentPage + 1;
383
+ fetchNextPage();
370
384
  } else {
371
385
  deferred.resolve({
372
386
  products: allProducts,
@@ -375,7 +389,7 @@ function productSearchAPI(deferred, options) {
375
389
  }
376
390
  })
377
391
  .catch((error) => {
378
- console.error(error);
392
+ console.error("Error fetching products:", error);
379
393
  deferred.reject(error);
380
394
  });
381
395
  }