@nuskin/ns-shop 7.1.9 → 7.2.1-mdigi-2049.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/ns-shop",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.2.1-mdigi-2049.1",
|
|
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,6 +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",
|
|
33
34
|
"axios": "1.6.5",
|
|
34
35
|
"decimal.js": "10.4.3",
|
|
35
36
|
"jp-conversion": "0.0.7",
|
|
@@ -6,9 +6,10 @@ 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";
|
|
9
10
|
|
|
10
11
|
let splitLineItems = [];
|
|
11
|
-
|
|
12
|
+
const utmInfo = storage.getItem(storage.metadata.UTM_INFO);
|
|
12
13
|
const addToCustomList = (customList, type, key, value) => {
|
|
13
14
|
if (value) {
|
|
14
15
|
let found = false;
|
|
@@ -136,7 +137,7 @@ const populateItem = (order, salesOrder, shipImmediate, includeSapItems) => {
|
|
|
136
137
|
};
|
|
137
138
|
|
|
138
139
|
const populateAttribution = (salesOrder) => {
|
|
139
|
-
const sponsorId = util.getSponsorId();
|
|
140
|
+
const sponsorId = util.getSponsorId();
|
|
140
141
|
const enableGuestCheckout = getCachedConfigField('enableGuestCheckout');
|
|
141
142
|
|
|
142
143
|
if (sponsorId) {
|
|
@@ -163,10 +164,22 @@ const populateAttribution = (salesOrder) => {
|
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
const getDefaultShipCode = () => {
|
|
168
|
+
let defaultCode = '';
|
|
169
|
+
const useShipMethodsApi = getCachedConfigField('useShipMethodsApi')
|
|
170
|
+
if (useShipMethodsApi) {
|
|
171
|
+
const csDefaultCode = getCachedConfigField('defaultShipMethod');
|
|
172
|
+
const shipMethods = PickupUtil.getStoredShipMethods();
|
|
173
|
+
const firstSm = shipMethods.length > 0 ? shipMethods[0].Code : '';
|
|
174
|
+
defaultCode = shipMethods.find((sm) => sm.Code === csDefaultCode) ? csDefaultCode : firstSm;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return defaultCode;
|
|
178
|
+
};
|
|
179
|
+
|
|
166
180
|
const populateShipping = (order, salesOrder) => {
|
|
167
181
|
const user = UserService.getUser();
|
|
168
|
-
const
|
|
169
|
-
const defaultCode = useShipMethodsApi ? getCachedConfigField('defaultShipMethod') : '';
|
|
182
|
+
const defaultCode = getDefaultShipCode();
|
|
170
183
|
const method = order.selectedShippingMethod;
|
|
171
184
|
const code = method ? method.Code : defaultCode;
|
|
172
185
|
|
|
@@ -479,6 +492,14 @@ const populateCategory = (salesOrder) => {
|
|
|
479
492
|
} else if (util.getSponsorId()) {
|
|
480
493
|
// affiliates don't use a subdomain. So if we have a sponsor and it isn't a pitch then we consider it a storefront
|
|
481
494
|
salesOrder.Category = "STOREFRONT";
|
|
495
|
+
} else if(utmInfo?.utm_medium){
|
|
496
|
+
if (utmInfo?.utm_medium.includes('paidsearch')) {
|
|
497
|
+
salesOrder.Category = 'PAIDSEARCH';
|
|
498
|
+
} else if (utmInfo?.utm_medium.includes('paidsocial')) {
|
|
499
|
+
salesOrder.Category = 'PAIDAD';
|
|
500
|
+
} else {
|
|
501
|
+
salesOrder.Category = 'WEB';
|
|
502
|
+
}
|
|
482
503
|
} else {
|
|
483
504
|
salesOrder.Category = 'WEB';
|
|
484
505
|
}
|
|
@@ -1014,6 +1035,12 @@ const populateSalesOrder = (action, adr) => {
|
|
|
1014
1035
|
if (user && user.isGuest) {
|
|
1015
1036
|
addToCustomList(salesOrder.Custom, "FLAG", "GUEST", "TRUE");
|
|
1016
1037
|
}
|
|
1038
|
+
addToCustomList(salesOrder.Custom, "FLAG", "UTM_SOURCE", utmInfo?.utm_source);
|
|
1039
|
+
addToCustomList(salesOrder.Custom, "FLAG", "UTM_MEDIUM", utmInfo?.utm_medium);
|
|
1040
|
+
addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN", utmInfo?.utm_campaign);
|
|
1041
|
+
addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN_ID", utmInfo?.utm_id);
|
|
1042
|
+
addToCustomList(salesOrder.Custom, "FLAG", "UTM_CONTENT", utmInfo?.utm_content);
|
|
1043
|
+
addToCustomList(salesOrder.Custom, "FLAG", "UTM_TERM", utmInfo?.utm_term);
|
|
1017
1044
|
const microsite = getCachedConfigField('microsite');
|
|
1018
1045
|
if (microsite) {
|
|
1019
1046
|
salesOrder.Reason = "CUSTOM";
|
|
@@ -201,10 +201,16 @@ let PickupUtil = function() {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
// if the calling code knows that loadShipMethods has finished then this
|
|
205
|
+
// function can be called directly if the calling function is not async.
|
|
206
|
+
function getStoredShipMethods() {
|
|
207
|
+
return JSON.parse((sessionStorage.getItem(SHIP_METHODS) || []));
|
|
208
|
+
}
|
|
209
|
+
|
|
204
210
|
async function getShipMethods() {
|
|
205
211
|
await promise;
|
|
206
212
|
|
|
207
|
-
return
|
|
213
|
+
return getStoredShipMethods();
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
async function getPickupPoints() {
|
|
@@ -221,6 +227,7 @@ let PickupUtil = function() {
|
|
|
221
227
|
markers: generateMarkers,
|
|
222
228
|
loadShipMethods,
|
|
223
229
|
getShipMethods,
|
|
230
|
+
getStoredShipMethods,
|
|
224
231
|
getPickupPoints
|
|
225
232
|
}
|
|
226
233
|
}();
|