@nuskin/ns-shop 7.2.0 → 7.2.1-mdigi-2049.2
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
|
@@ -137,7 +137,7 @@ const populateItem = (order, salesOrder, shipImmediate, includeSapItems) => {
|
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
const populateAttribution = (salesOrder) => {
|
|
140
|
-
const sponsorId = util.getSponsorId();
|
|
140
|
+
const sponsorId = util.getSponsorId();
|
|
141
141
|
const enableGuestCheckout = getCachedConfigField('enableGuestCheckout');
|
|
142
142
|
|
|
143
143
|
if (sponsorId) {
|
|
@@ -164,10 +164,22 @@ const populateAttribution = (salesOrder) => {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
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
|
+
|
|
167
180
|
const populateShipping = (order, salesOrder) => {
|
|
168
181
|
const user = UserService.getUser();
|
|
169
|
-
const
|
|
170
|
-
const defaultCode = useShipMethodsApi ? getCachedConfigField('defaultShipMethod') : '';
|
|
182
|
+
const defaultCode = getDefaultShipCode();
|
|
171
183
|
const method = order.selectedShippingMethod;
|
|
172
184
|
const code = method ? method.Code : defaultCode;
|
|
173
185
|
|
|
@@ -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
|
}();
|