@nuskin/ns-shop 5.14.1-4867-type.3 → 5.14.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-shop",
3
- "version": "5.14.1-4867-type.3",
3
+ "version": "5.14.2",
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": {
package/src/cart/cart.js CHANGED
@@ -857,7 +857,7 @@ export default function Cart(cartData) {
857
857
 
858
858
  if (eventNames.length > 0) {
859
859
  // make service call to get status of events on items
860
- const eventStatuses = await SalesEventService.getEventStatus(eventNames)
860
+ const eventStatuses = await SalesEventService.getEventStatus(eventNames, order.externalId);
861
861
  itemsChecked.forEach((item) => {
862
862
  const itemEvents = item.product.getEventPriceTypes();
863
863
  itemEvents.some((ie) => {
@@ -238,7 +238,7 @@ const getUrl = (path, pathParam, queryParams = {}) => {
238
238
  const queryStr = UrlService.toQueryString(queryParams);
239
239
  const queryString = queryStr.length > 0 ? `?${queryStr}` : '';
240
240
 
241
- return `https://devapi.cloud.nuskin.com/cart/v2/${path}/${pathParam}${queryString}`;
241
+ return `${ConfigService.getMarketConfig().awsUrl}/cart/v2/${path}/${pathParam}${queryString}`;
242
242
  };
243
243
 
244
244
  /**
@@ -562,7 +562,7 @@ const syncCart = async (type) => {
562
562
  let user = UserService.getUser();
563
563
  let pCart = null;
564
564
 
565
- if (user) {
565
+ if (user && type) {
566
566
  try {
567
567
  pCart = await getPersistedCart(user, type);
568
568
 
@@ -731,7 +731,10 @@ const timerCallback = () => {
731
731
  const addAction = (info) => {
732
732
  const user = UserService.getUser();
733
733
 
734
- if (!mergingIntoLocalCart && user) {
734
+ // If the code is currently merging the persistent cart into the local cart, cart update
735
+ // actions are being generated and those need to be ignored. A loadCart action is not is
736
+ // generated elsewhere and should be let through.
737
+ if (user && (info.loadCart || !mergingIntoLocalCart)) {
735
738
  if (info.add && info.add.item && !info.add.item.isBusinessPortfolio ||
736
739
  info.modify || info.remove || info.removeItems || info.removeCart || info.loadCart) {
737
740
  pcActions.push(info);
@@ -756,6 +759,7 @@ const loadPersistedCart = (type) => {
756
759
  const lsType = CartService.getCartProperty('type');
757
760
  if (type != lsType) {
758
761
  if (!documentReady) {
762
+ CartService.clearCart();
759
763
  CartService.setCartProperties({type: type});
760
764
  } else {
761
765
  addAction({loadCart: {type: type}});
@@ -140,12 +140,12 @@ function getActiveTicketEvents() {
140
140
  return events;
141
141
  }
142
142
 
143
- async function getEventStatus(eventsToCheck = []) {
143
+ async function getEventStatus(eventsToCheck = [], externalId = 'none') {
144
144
  const eventStatus = {};
145
145
  const promises = [];
146
146
 
147
147
  eventsToCheck.forEach((toCheck) => {
148
- promises.push(_getTempTicket(toCheck));
148
+ promises.push(_getTempTicket(toCheck, externalId));
149
149
  });
150
150
 
151
151
  const responses = await Promise.allSettled(promises);
@@ -173,15 +173,15 @@ async function getEventStatus(eventsToCheck = []) {
173
173
  * @returns {Promise<*>} a new or updated ticket for the specified event
174
174
  * @private
175
175
  */
176
- async function _getTempTicket(eventName) {
176
+ async function _getTempTicket(eventName, externalId) {
177
177
  let ticket;
178
178
 
179
179
  try {
180
180
  let method = 'POST',
181
- seParams = _getSeParams(eventName),
181
+ seParams = _getSeParams(eventName, false),
182
182
  response = await axios({
183
183
  method: method,
184
- url: `${_getAwsUrl(eventName, null)}${seParams}`,
184
+ url: `${_getAwsUrl(eventName, null)}?orderEventCheck=${externalId}${seParams}`,
185
185
  headers: _getHeaders(),
186
186
  timeout: 7000
187
187
  });