@nuskin/ns-shop 7.1.8 → 7.2.0

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.8",
3
+ "version": "7.2.0",
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;
@@ -137,9 +138,10 @@ const populateItem = (order, salesOrder, shipImmediate, includeSapItems) => {
137
138
 
138
139
  const populateAttribution = (salesOrder) => {
139
140
  const sponsorId = util.getSponsorId();
141
+ const enableGuestCheckout = getCachedConfigField('enableGuestCheckout');
140
142
 
141
143
  if (sponsorId) {
142
- if (sponsorId.match(/^[A-Z]{2,3}(:?\d{7}|\d{8})$/)) {
144
+ if (sponsorId.match(/^[A-Z]{2,3}(:?\d{7,8})$/)) {
143
145
  salesOrder.Shipping.ShippingParty.push({
144
146
  Type: "RTL_SELLER",
145
147
  ShippingMemberID: sponsorId,
@@ -149,7 +151,7 @@ const populateAttribution = (salesOrder) => {
149
151
  } else {
150
152
  console.error('Invalid sponsorId', sponsorId);
151
153
  }
152
- } else {
154
+ } else if(enableGuestCheckout) {
153
155
  const guestSponsorId = UserService.getUser();
154
156
  if(guestSponsorId.sponsorId == 'RETFLOAT' || guestSponsorId.sponsorId == 'NSHOUSE'){
155
157
  salesOrder.Shipping.ShippingParty.push({
@@ -478,6 +480,14 @@ const populateCategory = (salesOrder) => {
478
480
  } else if (util.getSponsorId()) {
479
481
  // affiliates don't use a subdomain. So if we have a sponsor and it isn't a pitch then we consider it a storefront
480
482
  salesOrder.Category = "STOREFRONT";
483
+ } else if(utmInfo?.utm_medium){
484
+ if (utmInfo?.utm_medium.includes('paidsearch')) {
485
+ salesOrder.Category = 'PAIDSEARCH';
486
+ } else if (utmInfo?.utm_medium.includes('paidsocial')) {
487
+ salesOrder.Category = 'PAIDAD';
488
+ } else {
489
+ salesOrder.Category = 'WEB';
490
+ }
481
491
  } else {
482
492
  salesOrder.Category = 'WEB';
483
493
  }
@@ -1013,6 +1023,12 @@ const populateSalesOrder = (action, adr) => {
1013
1023
  if (user && user.isGuest) {
1014
1024
  addToCustomList(salesOrder.Custom, "FLAG", "GUEST", "TRUE");
1015
1025
  }
1026
+ addToCustomList(salesOrder.Custom, "FLAG", "UTM_SOURCE", utmInfo?.utm_source);
1027
+ addToCustomList(salesOrder.Custom, "FLAG", "UTM_MEDIUM", utmInfo?.utm_medium);
1028
+ addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN", utmInfo?.utm_campaign);
1029
+ addToCustomList(salesOrder.Custom, "FLAG", "UTM_CAMPAIGN_ID", utmInfo?.utm_id);
1030
+ addToCustomList(salesOrder.Custom, "FLAG", "UTM_CONTENT", utmInfo?.utm_content);
1031
+ addToCustomList(salesOrder.Custom, "FLAG", "UTM_TERM", utmInfo?.utm_term);
1016
1032
  const microsite = getCachedConfigField('microsite');
1017
1033
  if (microsite) {
1018
1034
  salesOrder.Reason = "CUSTOM";