@nuskin/ns-shop 6.1.2 → 6.1.3
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": "6.1.
|
|
3
|
+
"version": "6.1.3",
|
|
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": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"request": "2.88.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@nuskin/configuration-sdk": "2.
|
|
38
|
+
"@nuskin/configuration-sdk": "2.2.0",
|
|
39
39
|
"@nuskin/ns-account": "4.28.0",
|
|
40
40
|
"@nuskin/ns-jsanalyzer": "1.0.1",
|
|
41
41
|
"@nuskin/ns-product": "3.36.2",
|
package/src/nuskin.shop.js
CHANGED
|
@@ -43,14 +43,14 @@ function Shop() {
|
|
|
43
43
|
try {
|
|
44
44
|
thisShop.updateCartLocal(resultObject);
|
|
45
45
|
$(document).trigger(events.shop.CART_RETURNED);
|
|
46
|
-
|
|
46
|
+
//events.publish(nuskin.events.shop.CART_RETURNED);
|
|
47
47
|
return true;
|
|
48
48
|
} catch(e) {
|
|
49
49
|
if (window.console) {
|
|
50
50
|
console.log(e);
|
|
51
51
|
}
|
|
52
52
|
$(document).trigger(events.shop.CART_RETURNED);
|
|
53
|
-
|
|
53
|
+
//events.publish(nuskin.events.shop.CART_RETURNED);
|
|
54
54
|
}
|
|
55
55
|
return false;
|
|
56
56
|
};
|
|
@@ -177,7 +177,7 @@ function Shop() {
|
|
|
177
177
|
if (result) {
|
|
178
178
|
let rv = result.length > 0 ? result[0] : result;
|
|
179
179
|
if (rv.hasOwnProperty("errorType")) {
|
|
180
|
-
|
|
180
|
+
events.publish(nuskin.events.shop.OUT_OF_STOCK, rv);
|
|
181
181
|
$('div.addedToCart').each(function() {
|
|
182
182
|
//if (item) item.style.display = 'block';
|
|
183
183
|
// eslint-disable-next-line
|
|
@@ -188,7 +188,7 @@ function Shop() {
|
|
|
188
188
|
let cart = {};
|
|
189
189
|
cart.itemCount = rv.currentItemCount;
|
|
190
190
|
nuskin.shop.updateCartLocal(cart);
|
|
191
|
-
|
|
191
|
+
events.publish(nuskin.events.shop.ADD_TO_CART, [{sku:window.lastAddedSku, quantity:rv.currentItemCount}]);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -321,7 +321,7 @@ function Shop() {
|
|
|
321
321
|
if (result.hasOwnProperty("messages") && result.messages.hasOwnProperty("failureMessages")) {
|
|
322
322
|
for (let i=0; i < result.messages.failureMessages.length; i++) {
|
|
323
323
|
if (result.messages.failureMessages[i] == 'outOfStock') {
|
|
324
|
-
|
|
324
|
+
events.publish(nuskin.events.shop.OUT_OF_STOCK, [{sku:sku, quantity:quantity}]); // cause out of stock to show
|
|
325
325
|
$('div.addedToCart').each(function() {
|
|
326
326
|
//if (item) item.style.display = 'block';
|
|
327
327
|
// eslint-disable-next-line
|
|
@@ -339,7 +339,7 @@ function Shop() {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// this event means that the items has been added to the cart???
|
|
342
|
-
|
|
342
|
+
events.publish(nuskin.events.shop.ADD_TO_CART, [{
|
|
343
343
|
sku:sku,
|
|
344
344
|
quantity:quantity,
|
|
345
345
|
maxqtyExceededMsg: maxqtyExceededMsg
|
|
@@ -405,7 +405,7 @@ function Shop() {
|
|
|
405
405
|
ajaxOptions.error = function(){};
|
|
406
406
|
ajaxOptions.success = function(result) {
|
|
407
407
|
if(cartReturnHandler(result)) {
|
|
408
|
-
|
|
408
|
+
events.publish(events.shop.ADD_TO_CART, [{sku:sku, quantity:quantity}]);
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
411
|
|
|
@@ -462,11 +462,11 @@ function Shop() {
|
|
|
462
462
|
if (UserService.getUser() !== null) {
|
|
463
463
|
FavoritesService.addToFavorites(sku).then(favorites => {
|
|
464
464
|
thisShop.favoritesList = favorites;
|
|
465
|
-
|
|
465
|
+
events.publish(events.shop.ADD_TO_FAVORITES_LIST);
|
|
466
466
|
}).catch(console.error);
|
|
467
467
|
} else {
|
|
468
468
|
window.showLoginPopup();
|
|
469
|
-
|
|
469
|
+
events.publish(events.shop.ADD_FAVORITES_LOGIN, sku);
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
472
|
|
|
@@ -507,7 +507,7 @@ function Shop() {
|
|
|
507
507
|
if (UserService.getUser() !== null) {
|
|
508
508
|
FavoritesService.getFavorites().then(favorites => {
|
|
509
509
|
thisShop.favoritesList = favorites;
|
|
510
|
-
|
|
510
|
+
events.publish(events.shop.FAVORITES_LIST_LOADED, thisShop.favoritesList);
|
|
511
511
|
}).catch(console.error);
|
|
512
512
|
}
|
|
513
513
|
};
|
|
@@ -556,7 +556,7 @@ function Shop() {
|
|
|
556
556
|
this.removeSKUFromFavoritesList = function(sku) {
|
|
557
557
|
FavoritesService.removeFromFavorites(sku).then(favorites => {
|
|
558
558
|
thisShop.favoritesList = favorites;
|
|
559
|
-
|
|
559
|
+
events.publish(events.shop.ITEM_REMOVED_FROM_FAVORITES);
|
|
560
560
|
}).catch(console.error);
|
|
561
561
|
};
|
|
562
562
|
|
|
@@ -669,17 +669,17 @@ function Shop() {
|
|
|
669
669
|
if (cartCookie) {
|
|
670
670
|
/* TODO: let me know if this is needed
|
|
671
671
|
var cart = JSON.parse(cartCookie);
|
|
672
|
-
|
|
672
|
+
events.setValue(events.shop.CART_UPDATED, [cart]);
|
|
673
673
|
*/
|
|
674
674
|
}
|
|
675
675
|
|
|
676
|
-
|
|
676
|
+
events.getValue(events.account.INIT_COMPLETE, function(/*object*/) {
|
|
677
677
|
thisShop.getCart();
|
|
678
678
|
},
|
|
679
679
|
true);
|
|
680
680
|
});
|
|
681
681
|
|
|
682
|
-
|
|
682
|
+
events.subscribe(events.authentication.LOGOUT_LEGACY, function(/*object*/) {
|
|
683
683
|
thisShop.resetCart();
|
|
684
684
|
});
|
|
685
685
|
|
|
@@ -697,10 +697,10 @@ function Shop() {
|
|
|
697
697
|
// TODO: may need to consider how we can handle any error if maxQty is exceeded
|
|
698
698
|
let maxqtyExceededMsg = null;
|
|
699
699
|
|
|
700
|
-
|
|
700
|
+
events.publish(events.shop.ADD_TO_CART, [{sku:sku, quantity:quantity, maxqtyExceededMsg: maxqtyExceededMsg}]); // shows the popup
|
|
701
701
|
} else {
|
|
702
|
-
|
|
703
|
-
|
|
702
|
+
events.publish(events.shop.ADD_TO_CART, [{sku:sku, quantity:quantity, maxqtyExceededMsg: null}]); // shows the popup
|
|
703
|
+
events.publish(events.shop.OUT_OF_STOCK, [{sku:atpResponse.sku, quantity:quantity}]); // cause out of stock to show
|
|
704
704
|
$('div.addedToCart').each(function(/*item*/) {
|
|
705
705
|
//if (item) item.style.display = 'block';
|
|
706
706
|
// eslint-disable-next-line
|
|
@@ -739,7 +739,7 @@ window.minicartCallback = function(cart) {
|
|
|
739
739
|
|
|
740
740
|
util.Initializer.addOnInit(function(){
|
|
741
741
|
if (util.isEcom3()) {
|
|
742
|
-
|
|
742
|
+
events.getValue(events.shop.CART_UPDATED, function (info) {
|
|
743
743
|
if (info) {
|
|
744
744
|
if (typeof nuskin.shop.updateCartLocal === 'function') {
|
|
745
745
|
nuskin.shop.updateCartLocal({itemCount:info.cartInfo.qty, psv: info.cartInfo.totalOrderPsv + info.cartInfo.totalAdrPsv});
|
|
@@ -144,7 +144,7 @@ let currentSubscriberBatch;
|
|
|
144
144
|
Product Status Service subscribes to the ADD_SKU_PRODUCT_STATUS_QUEUE event to
|
|
145
145
|
allow external code to request product status data through event publishing.
|
|
146
146
|
*/
|
|
147
|
-
|
|
147
|
+
events.subscribe(events.shop.ADD_SKU_PRODUCT_STATUS_QUEUE, queueForPublish);
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* The Product Status Service provides methods for retrieving product status
|
|
@@ -177,11 +177,11 @@ $.subscribe(events.shop.ADD_SKU_PRODUCT_STATUS_QUEUE, queueForPublish);
|
|
|
177
177
|
* <pre>
|
|
178
178
|
* let mySKU = '12345678';
|
|
179
179
|
*
|
|
180
|
-
*
|
|
180
|
+
* events.subscribe(events.shop.PRODUCT_STATUS_RESULT, statuses => {
|
|
181
181
|
* myStatus = statuses.find(stat => stat.SKU === mySKU);
|
|
182
182
|
* });
|
|
183
183
|
*
|
|
184
|
-
*
|
|
184
|
+
* events.publish(events.shop.ADD_SKU_PRODUCT_STATUS_QUEUE, mySKU);
|
|
185
185
|
* </pre>
|
|
186
186
|
*
|
|
187
187
|
* #### NOTE:
|
|
@@ -392,7 +392,7 @@ function publishStatuses() {
|
|
|
392
392
|
.then(lists => lists.filter(s => !!s).reduce((acc, el) => acc.concat(el), []))
|
|
393
393
|
|
|
394
394
|
// Publish the flattened list to all subscribers
|
|
395
|
-
.then(statuses =>
|
|
395
|
+
.then(statuses => events.publish(events.shop.PRODUCT_STATUS_RESULT, [statuses]))
|
|
396
396
|
.catch(console.error);
|
|
397
397
|
}
|
|
398
398
|
}
|
package/src/salesEventService.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import $ from '@nuskin/nuskinjquery';
|
|
2
1
|
import {RunConfigService, UrlService, events, storage} from '@nuskin/ns-util';
|
|
3
2
|
import axios from 'axios';
|
|
4
3
|
import { UserService } from '@nuskin/ns-account';
|
|
@@ -731,7 +730,7 @@ async function _initData(force) {
|
|
|
731
730
|
let loaded = false;
|
|
732
731
|
|
|
733
732
|
// initialize globals
|
|
734
|
-
if (
|
|
733
|
+
if (events.setValue && (force || (UrlService.isLocalePage() || storage.getItem('seParams')))) {
|
|
735
734
|
_loadSeParamEventNames();
|
|
736
735
|
await _loadMarketEventConfig(false);
|
|
737
736
|
_loadLocalEventTickets();
|