@nuskin/product-components 3.13.3 → 3.13.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.13.4](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.13.3...v3.13.4) (2024-02-16)
2
+
3
+
4
+ ### Fix
5
+
6
+ * Show the add to bag button ([1b6dc0a](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/1b6dc0ab319f58f9de828d216d7b213f395775d3))
7
+
1
8
  ## [3.13.3](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.13.2...v3.13.3) (2024-01-10)
2
9
 
3
10
 
@@ -94,7 +94,18 @@
94
94
  <span v-if="offerSavingsAfterHtml" v-html="offerSavingsAfterHtml" />
95
95
  </div>
96
96
 
97
- <!-- OFFER ACTION Vintas removed the Add to Bag button until the issue is fixed-->
97
+ <!-- OFFER ACTION -->
98
+ <div :class="$style.offerAction">
99
+ <button
100
+ class="primary-solid fluid"
101
+ :class="$style.button"
102
+ :disabled="disableAddAll"
103
+ @click="addFullOfferToCart"
104
+ >
105
+ <NsIcon :class="$style.addToCartIcon" icon-name="icon-bag" />
106
+ {{ localTranslations.addAllItems }}
107
+ </button>
108
+ </div>
98
109
  </div>
99
110
 
100
111
  <!-- OFFER PRODUCTS -->
@@ -177,11 +188,15 @@ import { MySiteRestService } from "@nuskin/my-site-api";
177
188
  import {
178
189
  CartService,
179
190
  CurrencyService,
180
- PersonalOfferService
191
+ PersonalOfferService,
192
+ EquinoxCartService,
193
+ Product as ShopProduct
181
194
  } from "@nuskin/ns-shop";
195
+ import { getCachedConfiguration } from "@nuskin/configuration-sdk";
182
196
  import { AccountService } from "@nuskin/ns-account";
183
197
  import { isNullOrEmpty, isNumber } from "@nuskin/ns-common-lib";
184
- import { NsSpinner } from "@nuskin/design-components";
198
+ // eslint-disable-next-line no-unused-vars
199
+ import { NsSpinner, NsIcon } from "@nuskin/design-components";
185
200
  import { waitForConfig } from "../services/configHelper";
186
201
  import debounce from "lodash/debounce";
187
202
 
@@ -736,11 +751,11 @@ export default {
736
751
  async addFullOfferToCart() {
737
752
  const validSkus = Object.keys(this.products).filter(sku => {
738
753
  const product = this.products[sku];
754
+ const availableQuantity = product.data.availableQuantity || 0;
739
755
  return (
740
756
  !product.invalid &&
741
757
  !isNullOrEmpty(product.data) &&
742
- !isNullOrEmpty(product.availability) &&
743
- product.availability.addToCart
758
+ availableQuantity >= 1
744
759
  );
745
760
  });
746
761
 
@@ -748,66 +763,76 @@ export default {
748
763
  return;
749
764
  }
750
765
 
751
- window.sessionStorage.setItem("nstoast-allowed", "true");
752
-
753
- const countryCode = CartService.getCartProperty("cntryCd") || "";
754
766
  let checkoutProducts = [];
755
- for (const validSku of validSkus) {
756
- const validProduct = this.products[validSku];
757
- const selectedSku = validProduct.activeSku;
758
- const selectedQuantity = validProduct.availability.selectedQuantity;
759
-
760
- const cartOptions = {
761
- sku: selectedSku,
762
- product: validProduct.data,
763
- qty: selectedQuantity,
764
- userId: this.userId,
765
- cntryCd: countryCode,
766
- adr: false,
767
- referrer: "myStore",
768
- domain: window.location.hostname
769
- };
767
+ const equinoxMarketsConfig = getCachedConfiguration("Equinox_Markets");
768
+ const countryCode = equinoxMarketsConfig.country_code;
770
769
 
771
- try {
772
- await CartService.addProductToCart(cartOptions);
773
-
774
- events.publish(events.shop.ADD_TO_CART, cartOptions);
775
-
776
- events.publish(events.shop.ADD_TO_CART_NEW, {
777
- event: "addToCart",
778
- ecommerce: {
779
- currencyCode: this.currencyCode,
780
- add: {
781
- actionField: {
782
- list: "myStore"
783
- },
784
- products: [
785
- {
786
- name: validProduct.data.title,
787
- id: selectedSku,
788
- price: validProduct.availability.price,
789
- quantity: selectedQuantity,
790
- method: "personaloffer", // personal offer or quickView or productPage or cart
791
- cartType: "Standard"
792
- }
793
- ]
794
- }
795
- }
770
+ if (equinoxMarketsConfig.active) {
771
+ EquinoxCartService.addBundleToEquinoxCart(validSkus)
772
+ .then(() => {
773
+ events.publish(events.shop.ADD_TO_CART);
774
+ })
775
+ .catch(err => {
776
+ console.error(`Failed to add ${validSkus} with Error: ${err} `);
796
777
  });
778
+ } else {
779
+ for (const validSku of validSkus) {
780
+ const validProduct = this.products[validSku];
781
+ const selectedSku = validProduct.activeSku;
782
+ const selectedQuantity = validProduct.availability.selectedQuantity;
783
+ const cartOptions = {
784
+ sku: selectedSku,
785
+ product: validProduct.data,
786
+ qty: selectedQuantity,
787
+ userId: this.userId,
788
+ cntryCd: countryCode,
789
+ adr: false,
790
+ referrer: "myStore",
791
+ domain: window.location.hostname
792
+ };
797
793
 
798
- // events.publish(events.shop.SHOW_ADD_TO_BAG, cartOptions);
799
-
800
- checkoutProducts.push({
801
- name: validProduct.data.title,
802
- id: selectedSku,
803
- price: validProduct.availability.price,
804
- quantity: selectedQuantity
805
- });
806
- } catch (error) {
807
- console.error(
808
- `Failed to add '${selectedSku}' x${selectedQuantity} to cart. Error: `,
809
- error
810
- );
794
+ cartOptions.product = new ShopProduct(cartOptions.product);
795
+ try {
796
+ await CartService.addProductToCart(cartOptions);
797
+
798
+ events.publish(events.shop.ADD_TO_CART, cartOptions);
799
+
800
+ events.publish(events.shop.ADD_TO_CART_NEW, {
801
+ event: "addToCart",
802
+ ecommerce: {
803
+ currencyCode: this.currencyCode,
804
+ add: {
805
+ actionField: {
806
+ list: "myStore"
807
+ },
808
+ products: [
809
+ {
810
+ name: validProduct.data.title,
811
+ id: selectedSku,
812
+ price: validProduct.availability.price,
813
+ quantity: selectedQuantity,
814
+ method: "personaloffer", // personal offer or quickView or productPage or cart
815
+ cartType: "Standard"
816
+ }
817
+ ]
818
+ }
819
+ }
820
+ });
821
+
822
+ // events.publish(events.shop.SHOW_ADD_TO_BAG, cartOptions);
823
+
824
+ checkoutProducts.push({
825
+ name: validProduct.data.title,
826
+ id: selectedSku,
827
+ price: validProduct.availability.price,
828
+ quantity: selectedQuantity
829
+ });
830
+ } catch (error) {
831
+ console.error(
832
+ `Failed to add '${selectedSku}' x${selectedQuantity} to cart. Error: `,
833
+ error
834
+ );
835
+ }
811
836
  }
812
837
  }
813
838
 
@@ -845,15 +870,21 @@ export default {
845
870
  for (const sku of Object.keys(this.products)) {
846
871
  this.products[sku].invalid = true;
847
872
  const availability = this.products[sku].availability;
848
- if (availability) {
873
+ const availableQuantity =
874
+ this.products[sku].data.availableQuantity || 0;
875
+
876
+ if (
877
+ availability &&
878
+ Object.keys(this.products[sku].data).length >= 1 &&
879
+ availableQuantity >= 1
880
+ ) {
849
881
  const selectedQuantity = availability.selectedQuantity || 0;
850
882
  if (selectedQuantity > 0) {
851
883
  const price = availability.price || 0;
852
- if (availability.addToCart) {
853
- totalPrice += price * selectedQuantity;
854
- this.totalProductQuantity += selectedQuantity;
855
- this.products[sku].invalid = false;
856
- }
884
+
885
+ totalPrice += price * selectedQuantity;
886
+ this.totalProductQuantity += selectedQuantity;
887
+ this.products[sku].invalid = false;
857
888
  }
858
889
  }
859
890
  }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "bomFormat": "CycloneDX",
3
3
  "specVersion": "1.4",
4
- "serialNumber": "urn:uuid:83b8375e-6791-473b-bea2-d24f88401c25",
4
+ "serialNumber": "urn:uuid:dfaf0a22-5464-4cc9-ace8-6e60d876a48d",
5
5
  "version": 1,
6
6
  "metadata": {
7
- "timestamp": "2024-01-10T07:42:02Z",
7
+ "timestamp": "2024-02-16T07:37:48Z",
8
8
  "tools": [
9
9
  {
10
10
  "vendor": "GitLab",
11
11
  "name": "Gemnasium",
12
- "version": "4.10.3"
12
+ "version": "4.10.6"
13
13
  }
14
14
  ],
15
15
  "authors": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/product-components",
3
- "version": "3.13.3",
3
+ "version": "3.13.4",
4
4
  "description": "Nu Skin Product Components",
5
5
  "main": "index.js",
6
6
  "scripts": {