@nuskin/product-components 3.18.0-cx24-6773.1 → 3.18.0-td-341.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/.releaserc +1 -1
- package/components/NsProductList.vue +21 -4
- package/components/NsProductOffer.vue +18 -2
- package/docs/CHANGELOG.md +1 -1
- package/mixins/NsProductMixin.js +120 -102
- package/package.json +3 -3
- package/services/EQPromotionService.js +36 -7
- package/services/NsProductAppService.js +29 -5
- package/services/NsProductDataService.js +5 -4
- package/stories/NsProductMixinPreview.vue +5 -34
- package/gl-sbom-npm-yarn.cdx.json +0 -3824
package/.releaserc
CHANGED
|
@@ -46,10 +46,12 @@
|
|
|
46
46
|
|
|
47
47
|
<script>
|
|
48
48
|
import { NsExpressiveLink, NsIcon, NsSpinner } from "@nuskin/design-components";
|
|
49
|
-
import { StringService } from "@nuskin/ns-util";
|
|
49
|
+
import { StringService, csStringService } from "@nuskin/ns-util";
|
|
50
50
|
import { fromJsonString } from "@nuskin/ns-common-lib";
|
|
51
|
+
import { getConfiguration } from "@nuskin/configuration-sdk";
|
|
51
52
|
|
|
52
53
|
import NsProductCard from "./NsProductCard.vue";
|
|
54
|
+
import { isEnabled } from "@nuskin/ns-feature-flags";
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* NsProductList
|
|
@@ -190,9 +192,24 @@ export default {
|
|
|
190
192
|
await this.$nextTick();
|
|
191
193
|
|
|
192
194
|
try {
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
const configs = await getConfiguration(["Mysite"]);
|
|
196
|
+
let useCSResources = false;
|
|
197
|
+
if (
|
|
198
|
+
configs &&
|
|
199
|
+
configs.Mysite &&
|
|
200
|
+
configs.Mysite.useCSResources &&
|
|
201
|
+
Array.isArray(configs.Mysite.useCSResources)
|
|
202
|
+
) {
|
|
203
|
+
useCSResources = configs.Mysite.useCSResources.includes(
|
|
204
|
+
this.runConfig.country
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
let commonStrings = {};
|
|
208
|
+
if (useCSResources && isEnabled("td_341")) {
|
|
209
|
+
commonStrings = await csStringService.getStrings(commonStringKeys);
|
|
210
|
+
} else {
|
|
211
|
+
commonStrings = await StringService.getStrings(commonStringKeys);
|
|
212
|
+
}
|
|
196
213
|
if (commonStrings && commonStrings.loadMore) {
|
|
197
214
|
this.loadMoreText = commonStrings.loadMore;
|
|
198
215
|
}
|
|
@@ -772,7 +772,13 @@ export default {
|
|
|
772
772
|
: this.products[sku].availableQuantity || 0;
|
|
773
773
|
const selectedQuantity = this.products[sku].availability
|
|
774
774
|
.selectedQuantity;
|
|
775
|
-
|
|
775
|
+
if (
|
|
776
|
+
this.products[sku].invalid ||
|
|
777
|
+
this.products[sku].data.availableQuantity <= 0 ||
|
|
778
|
+
!this.products[sku].availability.addToCart
|
|
779
|
+
) {
|
|
780
|
+
return undefined;
|
|
781
|
+
}
|
|
776
782
|
if (!this.products[sku].invalid && availableQuantity >= 1) {
|
|
777
783
|
selectedQuantityArr[
|
|
778
784
|
this.products[sku].activeSku
|
|
@@ -790,18 +796,27 @@ export default {
|
|
|
790
796
|
return;
|
|
791
797
|
}
|
|
792
798
|
|
|
799
|
+
let options = {
|
|
800
|
+
add: {
|
|
801
|
+
item: {
|
|
802
|
+
qty: this.totalProductQuantity
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
|
|
793
807
|
let checkoutProducts = [];
|
|
794
808
|
const equinoxMarketsConfig = getCachedConfiguration("Equinox_Markets");
|
|
795
809
|
const countryCode = equinoxMarketsConfig.country_code;
|
|
796
810
|
|
|
797
811
|
if (equinoxMarketsConfig.active) {
|
|
812
|
+
window.sessionStorage.setItem("nstoast-allowed", "true");
|
|
798
813
|
EquinoxCartService.addBundleToEquinoxCart(
|
|
799
814
|
validSkus,
|
|
800
815
|
this.products,
|
|
801
816
|
selectedQuantityArr
|
|
802
817
|
)
|
|
803
818
|
.then(() => {
|
|
804
|
-
events.publish(events.shop.ADD_TO_CART);
|
|
819
|
+
events.publish(events.shop.ADD_TO_CART, options);
|
|
805
820
|
})
|
|
806
821
|
.catch(err => {
|
|
807
822
|
console.error(`Failed to add ${validSkus} with Error: ${err} `);
|
|
@@ -906,6 +921,7 @@ export default {
|
|
|
906
921
|
|
|
907
922
|
if (
|
|
908
923
|
availability &&
|
|
924
|
+
availability.addToCart &&
|
|
909
925
|
Object.keys(this.products[sku].data).length >= 1 &&
|
|
910
926
|
availableQuantity >= 1
|
|
911
927
|
) {
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# [3.18.0-
|
|
1
|
+
# [3.18.0-td-341.1](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.17.15...v3.18.0-td-341.1) (2024-10-22)
|
package/mixins/NsProductMixin.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
events,
|
|
8
8
|
StringService,
|
|
9
|
+
csStringService,
|
|
9
10
|
util,
|
|
10
11
|
SitesSessionStorageService,
|
|
11
12
|
ShoppingContext,
|
|
@@ -21,12 +22,11 @@ import {
|
|
|
21
22
|
AdrService,
|
|
22
23
|
FavoritesService,
|
|
23
24
|
ProductStatus,
|
|
24
|
-
QualificationService as OldQualificationService,
|
|
25
25
|
Product as ShopProduct,
|
|
26
26
|
EquinoxCartService
|
|
27
27
|
} from "@nuskin/ns-shop";
|
|
28
|
-
import {
|
|
29
|
-
import
|
|
28
|
+
import { isEnabled } from "@nuskin/ns-feature-flags";
|
|
29
|
+
import QualificationService from "@nuskin/exclusive-offer-sdk";
|
|
30
30
|
import webLoyalty from "@nuskin/ns-loyalty-web";
|
|
31
31
|
import { getProp, getFullUrl } from "@nuskin/ns-common-lib";
|
|
32
32
|
import { PriceType } from "@nuskin/ns-product-lib";
|
|
@@ -38,31 +38,6 @@ const PENDING_FAVORITE = "pendingFavorite";
|
|
|
38
38
|
const KEY_BREADCRUMB_BACK = "breadcrumbBack";
|
|
39
39
|
const BUNDLE = "BUNDLE";
|
|
40
40
|
|
|
41
|
-
let flagsPromise = null;
|
|
42
|
-
let featureFlags = false;
|
|
43
|
-
const checkFlag = async flag => {
|
|
44
|
-
if (!featureFlags && !flagsPromise) {
|
|
45
|
-
flagsPromise = retrieveTogglesBasedOnEnvironment().then(
|
|
46
|
-
flagsFromServer => (featureFlags = flagsFromServer)
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!featureFlags) {
|
|
51
|
-
await flagsPromise;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return featureFlags.has(flag);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const getQualificationService = async () => {
|
|
58
|
-
const equinoxMarket = (await getConfiguration(["Equinox_Markets"]))
|
|
59
|
-
.Equinox_Markets;
|
|
60
|
-
return equinoxMarket.active ||
|
|
61
|
-
(await checkFlag("cx15_use_new_exclusive_offer_api"))
|
|
62
|
-
? NewQualificationService
|
|
63
|
-
: OldQualificationService;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
41
|
/**
|
|
67
42
|
* NsProductMixin
|
|
68
43
|
*
|
|
@@ -273,7 +248,11 @@ const NsProductMixin = {
|
|
|
273
248
|
return this.$NsProductUserService.isPreferredCustomer;
|
|
274
249
|
},
|
|
275
250
|
isWholesale() {
|
|
276
|
-
|
|
251
|
+
if (this.$NsProductUserService.isLoggedIn) {
|
|
252
|
+
return this.$NsProductUserService.isUserWholesale;
|
|
253
|
+
} else {
|
|
254
|
+
return this.$NsProductUserService.isWholesale;
|
|
255
|
+
}
|
|
277
256
|
},
|
|
278
257
|
loyaltyStatusAndLinks() {
|
|
279
258
|
return this.marketConfig.loyalty || {};
|
|
@@ -495,8 +474,44 @@ const NsProductMixin = {
|
|
|
495
474
|
this.loyaltyStatusAndLinks.productOptedInRedeemNotEarn =
|
|
496
475
|
"Save with Nu Skin Rewards";
|
|
497
476
|
|
|
498
|
-
|
|
499
|
-
|
|
477
|
+
const commonStringKeys = [
|
|
478
|
+
{ key: "productDisplayNotOptedinMessage", dflt: "" },
|
|
479
|
+
{
|
|
480
|
+
key: "productDisplayOptedinMessage",
|
|
481
|
+
dflt: "{earnPercentage} Nu Skin enJoy Rewards Available!"
|
|
482
|
+
},
|
|
483
|
+
{ key: "productOptedInEarnNotRedeem", dflt: "" },
|
|
484
|
+
{
|
|
485
|
+
key: "productOptedInRedeemNotEarn",
|
|
486
|
+
dflt:
|
|
487
|
+
"This product does not earn rewards points but is available to be redeemed for rewards points."
|
|
488
|
+
}
|
|
489
|
+
];
|
|
490
|
+
|
|
491
|
+
try {
|
|
492
|
+
const configs = await getConfiguration(["Mysite"]);
|
|
493
|
+
let useCSResources = false;
|
|
494
|
+
if (
|
|
495
|
+
configs &&
|
|
496
|
+
configs.Mysite &&
|
|
497
|
+
configs.Mysite.useCSResources &&
|
|
498
|
+
Array.isArray(configs.Mysite.useCSResources)
|
|
499
|
+
) {
|
|
500
|
+
useCSResources = configs.Mysite.useCSResources.includes(
|
|
501
|
+
this.runConfig.country
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
let loyalityStringsContent = {};
|
|
505
|
+
if (useCSResources && isEnabled("td_341")) {
|
|
506
|
+
loyalityStringsContent = await csStringService.getStrings(
|
|
507
|
+
commonStringKeys
|
|
508
|
+
);
|
|
509
|
+
} else {
|
|
510
|
+
loyalityStringsContent = await StringService.getStrings(
|
|
511
|
+
commonStringKeys
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
this.loyaltyStrings = loyalityStringsContent;
|
|
500
515
|
// Link message to show to non-opted in users
|
|
501
516
|
if (this.loyaltyStrings.productDisplayNotOptedinMessage) {
|
|
502
517
|
this.loyaltyStatusAndLinks.landingPageLinkMessage = this.loyaltyStrings.productDisplayNotOptedinMessage;
|
|
@@ -538,12 +553,14 @@ const NsProductMixin = {
|
|
|
538
553
|
);
|
|
539
554
|
this.userLoyalty = loyaltyData;
|
|
540
555
|
}
|
|
541
|
-
});
|
|
542
556
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
557
|
+
this.loyaltyStatusAndLinks.landingPage = this.localeReplace(
|
|
558
|
+
this.loyaltyStatusAndLinks.dashboardPage
|
|
559
|
+
);
|
|
560
|
+
this.loyaltyStatusAndLinks.siteUrl = this.siteUrl;
|
|
561
|
+
} catch (err) {
|
|
562
|
+
console.warn("Unable to retrieve loyalty strings translations.", err);
|
|
563
|
+
}
|
|
547
564
|
}
|
|
548
565
|
},
|
|
549
566
|
|
|
@@ -672,25 +689,31 @@ const NsProductMixin = {
|
|
|
672
689
|
if (this.product) {
|
|
673
690
|
// WARNING: There's a instanceof check on CartService.getAddToCartQty for the ns-shop Product, previously different
|
|
674
691
|
const shopProduct = new ShopProduct(this.product);
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
692
|
+
|
|
693
|
+
getConfiguration(["Equinox_Markets"]).then(({ Equinox_Markets }) => {
|
|
694
|
+
const { active } = Equinox_Markets;
|
|
695
|
+
|
|
696
|
+
const cartService = active ? EquinoxCartService : CartService;
|
|
697
|
+
// check if a user is qualified to purchase the product
|
|
698
|
+
cartService
|
|
699
|
+
.getAddToCartQty(shopProduct)
|
|
700
|
+
.then(productQuantity => {
|
|
701
|
+
// WARNING: this.product is volatile here. re-check is using this.product.
|
|
702
|
+
this.maxQuantity = Math.min(
|
|
703
|
+
shopProduct.maxQuantity,
|
|
704
|
+
productQuantity
|
|
705
|
+
);
|
|
706
|
+
})
|
|
707
|
+
.catch(error => {
|
|
708
|
+
this.maxQuantity = shopProduct.maxQuantity;
|
|
709
|
+
console.error("Failed to retrieve add to cart quantity.", error);
|
|
710
|
+
})
|
|
711
|
+
.finally(() => {
|
|
712
|
+
this.setStatus();
|
|
713
|
+
this.checkedQualifications = true;
|
|
714
|
+
this.emitAvailability();
|
|
715
|
+
});
|
|
716
|
+
});
|
|
694
717
|
}
|
|
695
718
|
},
|
|
696
719
|
|
|
@@ -723,6 +746,24 @@ const NsProductMixin = {
|
|
|
723
746
|
)
|
|
724
747
|
);
|
|
725
748
|
this.statusMessageKey = "backOrderedWithDate";
|
|
749
|
+
|
|
750
|
+
let backOrderDate = new Date(this.product.backOrderDate);
|
|
751
|
+
let today = new Date();
|
|
752
|
+
if (backOrderDate < today) {
|
|
753
|
+
if (this.product.availableQuantity > 0) {
|
|
754
|
+
this.statusMessage = "";
|
|
755
|
+
this.statusMessageKey = "releasedForSale";
|
|
756
|
+
//BRW-4541 -- Only allow to purchase the atpQuantity if backorder date is in the past
|
|
757
|
+
this.maxQuantity = Math.min(
|
|
758
|
+
this.product.maxQuantity,
|
|
759
|
+
this.product.availableQuantity
|
|
760
|
+
);
|
|
761
|
+
} else {
|
|
762
|
+
this.statusMessage = this.localTranslations.outOfStock;
|
|
763
|
+
this.statusMessageKey = "outOfStock";
|
|
764
|
+
this.disable();
|
|
765
|
+
}
|
|
766
|
+
}
|
|
726
767
|
}
|
|
727
768
|
} else {
|
|
728
769
|
this.disable();
|
|
@@ -755,9 +796,9 @@ const NsProductMixin = {
|
|
|
755
796
|
this.exclusiveOfferMessage = "";
|
|
756
797
|
if (this.isExclusive) {
|
|
757
798
|
if (this.isLoggedIn) {
|
|
758
|
-
const productQualification = await (
|
|
759
|
-
|
|
760
|
-
)
|
|
799
|
+
const productQualification = await QualificationService.getQualification(
|
|
800
|
+
this.activeSku
|
|
801
|
+
);
|
|
761
802
|
|
|
762
803
|
let cartQuantity = 0;
|
|
763
804
|
|
|
@@ -787,10 +828,10 @@ const NsProductMixin = {
|
|
|
787
828
|
cartQuantity = (cartItem || {}).qty || 0;
|
|
788
829
|
} else {
|
|
789
830
|
const cartData =
|
|
790
|
-
(await (
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
{};
|
|
831
|
+
(await QualificationService.convertCartDataToBaseSkus(
|
|
832
|
+
CartService.getItemData(),
|
|
833
|
+
true
|
|
834
|
+
)) || {};
|
|
794
835
|
const cartItem = cartData[this.baseSku] || {};
|
|
795
836
|
cartQuantity = cartItem.qty || 0;
|
|
796
837
|
}
|
|
@@ -835,22 +876,8 @@ const NsProductMixin = {
|
|
|
835
876
|
* Set product pricing
|
|
836
877
|
*/
|
|
837
878
|
setStandardPricing() {
|
|
838
|
-
const equinoxMarketsConfig = getCachedConfiguration("Equinox_Markets");
|
|
839
|
-
const isGraphQLActive = equinoxMarketsConfig.MySite_graphql_active;
|
|
840
|
-
|
|
841
879
|
// set price and points
|
|
842
880
|
this.originalPrice = this.product.getPricing(PriceType.WRTL);
|
|
843
|
-
|
|
844
|
-
//graphQL adjustments
|
|
845
|
-
if (isGraphQLActive) {
|
|
846
|
-
this.originalPrice =
|
|
847
|
-
this.product.childSkus &&
|
|
848
|
-
this.product.childSkus.length &&
|
|
849
|
-
this.getPriceType() === PriceType.WWHL
|
|
850
|
-
? this.product.getPricing(PriceType.WHL)
|
|
851
|
-
: this.product.getPricing(PriceType.RTL);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
881
|
this.priceType = this.getPriceType();
|
|
855
882
|
this.price = this.product.getPricing(this.priceType);
|
|
856
883
|
this.points = this.product.getPvFixed();
|
|
@@ -902,33 +929,20 @@ const NsProductMixin = {
|
|
|
902
929
|
// set sales event pricing and points
|
|
903
930
|
this.originalPriceType = this.product.priceType;
|
|
904
931
|
|
|
905
|
-
this.originalPrice =
|
|
906
|
-
isEquinoxEnabled && !isGraphQLActive
|
|
907
|
-
? this.product.getPricing(PriceType.WRTL)
|
|
908
|
-
: this.product.getOriginalPrice();
|
|
909
|
-
|
|
910
|
-
//workaround for graphQL active to show original price
|
|
911
932
|
if (isGraphQLActive) {
|
|
912
|
-
this.originalPrice =
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
? this.product.getPricing(PriceType.WHL)
|
|
917
|
-
: this.product.getPricing(PriceType.RTL);
|
|
933
|
+
this.originalPrice = this.product.getPricing(this.originalPriceType);
|
|
934
|
+
this.product.priceType = `${this.eventName}-${this.originalPriceType}`;
|
|
935
|
+
} else {
|
|
936
|
+
this.product.getOriginalPrice();
|
|
918
937
|
}
|
|
919
938
|
|
|
920
939
|
this.priceType = this.product.priceType;
|
|
921
|
-
|
|
922
|
-
this.price = this.product.getPrice();
|
|
940
|
+
this.price = this.product.getPricing(this.priceType);
|
|
923
941
|
|
|
924
942
|
//If EQ market, always show the discounted price if product has promotion
|
|
925
943
|
//Hence, we set the price to member(wholesale / PriceType.WADW) if the price type PriceType.WADR (retail)
|
|
926
944
|
//this is inline with the change in business rules to always show the discounted prices
|
|
927
|
-
if (
|
|
928
|
-
isEquinoxEnabled &&
|
|
929
|
-
!isGraphQLActive &&
|
|
930
|
-
this.getAdrPriceType() == PriceType.WADR
|
|
931
|
-
) {
|
|
945
|
+
if (isGraphQLActive && this.getAdrPriceType() == PriceType.WADR) {
|
|
932
946
|
this.adrPrice = this.product.getPricing(PriceType.WADW);
|
|
933
947
|
}
|
|
934
948
|
|
|
@@ -937,13 +951,9 @@ const NsProductMixin = {
|
|
|
937
951
|
//for product that has promotion
|
|
938
952
|
//set the price to WWHL if this.getPriceType() === WRTL
|
|
939
953
|
//promotion price is set in product.js setPriceAndPvFromType function
|
|
940
|
-
if (
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
this.getPriceType() == PriceType.WRTL
|
|
944
|
-
) {
|
|
945
|
-
this.price = this.product.getPricing(PriceType.WWHL);
|
|
946
|
-
}
|
|
954
|
+
// if (isGraphQLActive && this.getPriceType() == PriceType.WRTL) {
|
|
955
|
+
// this.price = this.product.getPricing(PriceType.WWHL);
|
|
956
|
+
// }
|
|
947
957
|
|
|
948
958
|
if (this.user && this.isDistributor) {
|
|
949
959
|
this.points = this.product.getPvFixed();
|
|
@@ -1162,6 +1172,14 @@ const NsProductMixin = {
|
|
|
1162
1172
|
productToAdd.equinoxProductId = productIdentifier;
|
|
1163
1173
|
//productToAdd.properties = productData.products[0].properties
|
|
1164
1174
|
}
|
|
1175
|
+
if (
|
|
1176
|
+
productToAdd.backOrderDate &&
|
|
1177
|
+
new Date(productToAdd.backOrderDate) > new Date()
|
|
1178
|
+
) {
|
|
1179
|
+
productToAdd.inventory = "BACKORDER";
|
|
1180
|
+
productToAdd.properties.isBackOrdered = true;
|
|
1181
|
+
productToAdd.properties.inventoryStatus = "BACKORDER";
|
|
1182
|
+
}
|
|
1165
1183
|
options.product = new ShopProduct(productToAdd);
|
|
1166
1184
|
options.add = {
|
|
1167
1185
|
item: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/product-components",
|
|
3
|
-
"version": "3.18.0-
|
|
3
|
+
"version": "3.18.0-td-341.1",
|
|
4
4
|
"description": "Nu Skin Product Components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@nuskin/ns-core-styles": "2.11.2",
|
|
30
30
|
"@nuskin/ns-icon": "^2.12.0",
|
|
31
31
|
"@nuskin/ns-loyalty-web": "1.5.6",
|
|
32
|
-
"@nuskin/ns-product-lib": "2.
|
|
33
|
-
"@nuskin/ns-shop": "
|
|
32
|
+
"@nuskin/ns-product-lib": "2.19.0",
|
|
33
|
+
"@nuskin/ns-shop": "7.0.10",
|
|
34
34
|
"@nuskin/product-recommendation": "2.0.1",
|
|
35
35
|
"axios": "1.6.7",
|
|
36
36
|
"lodash": "4.17.21",
|
|
@@ -41,6 +41,8 @@ const buildPayload = product => {
|
|
|
41
41
|
let personalOffer = sessionStorage.getItem("personalOffer");
|
|
42
42
|
if (personalOffer !== null) {
|
|
43
43
|
personalOffer = JSON.parse(personalOffer);
|
|
44
|
+
} else {
|
|
45
|
+
personalOffer = { products: [] };
|
|
44
46
|
}
|
|
45
47
|
const matchedProduct = personalOffer.products.filter(
|
|
46
48
|
offerProduct => offerProduct.sku === product.sku
|
|
@@ -55,18 +57,45 @@ const buildPayload = product => {
|
|
|
55
57
|
const skus = [];
|
|
56
58
|
if (product && product.childSkus) {
|
|
57
59
|
product.childSkus.forEach(childSku => {
|
|
58
|
-
if (
|
|
60
|
+
if (
|
|
61
|
+
childSku.type === "MANDATORY" &&
|
|
62
|
+
!skus.some(sku => sku.productId === childSku.productId)
|
|
63
|
+
) {
|
|
59
64
|
skus.push({
|
|
60
|
-
skuId:
|
|
61
|
-
selectedVariants !== null && selectedVariants[childSku.productId]
|
|
62
|
-
? selectedVariants[childSku.productId]
|
|
63
|
-
: childSku.skuId,
|
|
65
|
+
skuId: childSku.skuId,
|
|
64
66
|
productId: childSku.productId,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
type: "bundle",
|
|
68
|
+
quantity: childSku.skuQuantity
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
});
|
|
72
|
+
|
|
73
|
+
if (selectedVariants !== null) {
|
|
74
|
+
for (const productId in selectedVariants) {
|
|
75
|
+
let isOptionalProduct = true;
|
|
76
|
+
skus.forEach(finalSku => {
|
|
77
|
+
if (finalSku.productId === productId) {
|
|
78
|
+
isOptionalProduct = false;
|
|
79
|
+
finalSku.skuId = selectedVariants[productId];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (isOptionalProduct) {
|
|
84
|
+
// this means this is optional product
|
|
85
|
+
const optionalProduct = product.childSkus.filter(
|
|
86
|
+
childSku => childSku.productId === productId
|
|
87
|
+
)[0];
|
|
88
|
+
if (optionalProduct) {
|
|
89
|
+
skus.push({
|
|
90
|
+
skuId: selectedVariants[productId],
|
|
91
|
+
productId: optionalProduct.productId,
|
|
92
|
+
type: "bundle",
|
|
93
|
+
quantity: optionalProduct.skuQuantity
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
70
99
|
}
|
|
71
100
|
|
|
72
101
|
payload.skus = skus;
|
|
@@ -3,8 +3,11 @@ import Vue from "vue";
|
|
|
3
3
|
import {
|
|
4
4
|
RunConfigService,
|
|
5
5
|
ConfigService,
|
|
6
|
-
StringService
|
|
6
|
+
StringService,
|
|
7
|
+
csStringService
|
|
7
8
|
} from "@nuskin/ns-util";
|
|
9
|
+
import { getConfiguration } from "@nuskin/configuration-sdk";
|
|
10
|
+
import { isEnabled } from "@nuskin/ns-feature-flags";
|
|
8
11
|
|
|
9
12
|
import { isNullOrEmpty } from "@nuskin/ns-common-lib";
|
|
10
13
|
|
|
@@ -177,10 +180,31 @@ if (!NsProductAppService) {
|
|
|
177
180
|
];
|
|
178
181
|
|
|
179
182
|
try {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
const configs = await getConfiguration(["Mysite"]);
|
|
184
|
+
let useCSResources = false;
|
|
185
|
+
if (
|
|
186
|
+
configs &&
|
|
187
|
+
configs.Mysite &&
|
|
188
|
+
configs.Mysite.useCSResources &&
|
|
189
|
+
Array.isArray(configs.Mysite.useCSResources)
|
|
190
|
+
) {
|
|
191
|
+
useCSResources = configs.Mysite.useCSResources.includes(
|
|
192
|
+
this.runConfig.country
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let commonStrings = {};
|
|
197
|
+
if (useCSResources && isEnabled("td_341")) {
|
|
198
|
+
commonStrings = await csStringService.getStrings(
|
|
199
|
+
commonStringKeys,
|
|
200
|
+
this.locale
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
commonStrings = await StringService.getStrings(
|
|
204
|
+
commonStringKeys,
|
|
205
|
+
this.locale
|
|
206
|
+
);
|
|
207
|
+
}
|
|
184
208
|
|
|
185
209
|
this.appendTranslations(commonStrings);
|
|
186
210
|
} catch (err) {
|
|
@@ -9,7 +9,10 @@ import { isNullOrEmpty } from "@nuskin/ns-common-lib";
|
|
|
9
9
|
import { ProductDataService } from "@nuskin/ns-product";
|
|
10
10
|
import { Product, PriceType } from "@nuskin/ns-product-lib";
|
|
11
11
|
import { equinoxLocalStorage } from "@nuskin/ns-util";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
getConfiguration,
|
|
14
|
+
getCachedConfiguration
|
|
15
|
+
} from "@nuskin/configuration-sdk";
|
|
13
16
|
|
|
14
17
|
class ProductDataBatch {
|
|
15
18
|
constructor(id, skus) {
|
|
@@ -269,9 +272,7 @@ if (!NsProductDataService) {
|
|
|
269
272
|
return;
|
|
270
273
|
}
|
|
271
274
|
|
|
272
|
-
const equinoxMarketConfig = (
|
|
273
|
-
await getConfiguration(["Equinox_Markets"])
|
|
274
|
-
).Equinox_Markets;
|
|
275
|
+
const equinoxMarketConfig = getCachedConfiguration("Equinox_Markets");
|
|
275
276
|
|
|
276
277
|
// product data response has products
|
|
277
278
|
if (productData.count && productData.products.length) {
|
|
@@ -200,40 +200,11 @@
|
|
|
200
200
|
</template>
|
|
201
201
|
|
|
202
202
|
<script>
|
|
203
|
-
import {
|
|
204
|
-
|
|
205
|
-
CartService
|
|
206
|
-
} from "@nuskin/ns-shop";
|
|
207
|
-
import { getConfiguration } from "@nuskin/configuration-sdk";
|
|
208
|
-
import { default as NewQualificationService } from "@nuskin/exclusive-offer-sdk";
|
|
203
|
+
import { CartService } from "@nuskin/ns-shop";
|
|
204
|
+
import QualificationService from "@nuskin/exclusive-offer-sdk";
|
|
209
205
|
import NsProductMixin from "../mixins/NsProductMixin";
|
|
210
206
|
import "@nuskin/ns-core-styles/src/dist/main.css";
|
|
211
207
|
|
|
212
|
-
let equinoxMarket = {
|
|
213
|
-
promise: getConfiguration(["Equinox_Markets"]).then(config => {
|
|
214
|
-
equinoxMarket = {
|
|
215
|
-
value:
|
|
216
|
-
config && config.Equinox_Markets
|
|
217
|
-
? !!config.Equinox_Markets.active
|
|
218
|
-
: false,
|
|
219
|
-
promise: null,
|
|
220
|
-
loaded: true
|
|
221
|
-
};
|
|
222
|
-
}),
|
|
223
|
-
loaded: false,
|
|
224
|
-
value: undefined
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const getQualificationService = async () => {
|
|
228
|
-
if (!equinoxMarket.loaded) {
|
|
229
|
-
await equinoxMarket.promise;
|
|
230
|
-
}
|
|
231
|
-
if (equinoxMarket.value) {
|
|
232
|
-
return NewQualificationService;
|
|
233
|
-
}
|
|
234
|
-
return OldQualificationService;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
208
|
export default {
|
|
238
209
|
name: "NsProductMixinPreview",
|
|
239
210
|
filters: {
|
|
@@ -407,9 +378,9 @@ export default {
|
|
|
407
378
|
async mounted() {
|
|
408
379
|
if (this.isExclusive) {
|
|
409
380
|
if (this.isLoggedIn) {
|
|
410
|
-
this.productQualification = await (
|
|
411
|
-
|
|
412
|
-
)
|
|
381
|
+
this.productQualification = await QualificationService.getQualification(
|
|
382
|
+
this.activeSku
|
|
383
|
+
);
|
|
413
384
|
|
|
414
385
|
this.cartItem = await CartService.getFirstItemBySku(this.activeSku, {
|
|
415
386
|
cartOrderItems: true
|