@nuskin/ns-shop 7.3.0-mdigi-897.8 → 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.
|
|
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,7 +30,6 @@
|
|
|
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
33
|
"axios": "1.7.9",
|
|
35
34
|
"decimal.js": "10.4.3",
|
|
36
35
|
"jp-conversion": "0.0.7",
|
|
@@ -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,10 +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.utm_medium && utmInfo.utm_medium.includes('paidsearch')) {
|
|
501
|
-
salesOrder.Category = 'PAIDSEARCH';
|
|
502
|
-
} else if (utmInfo.utm_medium && utmInfo.utm_medium.includes('paidsocial')) {
|
|
503
|
-
salesOrder.Category = 'PAIDAD';
|
|
504
498
|
} else {
|
|
505
499
|
salesOrder.Category = 'WEB';
|
|
506
500
|
}
|
|
@@ -1036,12 +1030,6 @@ const populateSalesOrder = (action, adr) => {
|
|
|
1036
1030
|
if (user && user.isGuest) {
|
|
1037
1031
|
addToCustomList(salesOrder.Custom, "FLAG", "GUEST", "TRUE");
|
|
1038
1032
|
}
|
|
1039
|
-
addToCustomList(salesOrder.Custom, "FLAG", "UTM_SOURCE", utmInfo.utm_source);
|
|
1040
|
-
addToCustomList(salesOrder.Custom, "FLAG", "UTM_MEDIUM", utmInfo.utm_medium);
|
|
1041
|
-
addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN", utmInfo.utm_campaign);
|
|
1042
|
-
addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN_ID", utmInfo.utm_id);
|
|
1043
|
-
addToCustomList(salesOrder.Custom, "FLAG", "UTM_CONTENT", utmInfo.utm_content);
|
|
1044
|
-
addToCustomList(salesOrder.Custom, "FLAG", "UTM_TERM", utmInfo.utm_term);
|
|
1045
1033
|
const microsite = getCachedConfigField('microsite');
|
|
1046
1034
|
if (microsite) {
|
|
1047
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
|
-
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
}
|