@anker-in/shopify-react 0.1.1-beta.40 → 0.1.1-beta.42

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.
@@ -4,7 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
4
4
  import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.mjs';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { SWRConfiguration } from 'swr';
7
- import { e as PlusMemberSettingsMetafields } from '../types-BSsb8OPm.mjs';
7
+ import { e as PlusMemberSettingsMetafields } from '../types-DntkHhf8.mjs';
8
8
 
9
9
  interface ShopifyContextValue {
10
10
  client: ShopifyClient;
@@ -4,7 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
4
4
  import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { SWRConfiguration } from 'swr';
7
- import { e as PlusMemberSettingsMetafields } from '../types-BSsb8OPm.js';
7
+ import { e as PlusMemberSettingsMetafields } from '../types-DntkHhf8.js';
8
8
 
9
9
  interface ShopifyContextValue {
10
10
  client: ShopifyClient;
@@ -711,24 +711,31 @@ var useScriptAutoFreeGift = ({
711
711
  giftProductsResult: finalGiftProductsResult
712
712
  };
713
713
  };
714
- function useUpdateCartAttributes(mutate, metafieldIdentifiers, options) {
714
+ function useUpdateCartAttributes({
715
+ mutate,
716
+ metafieldIdentifiers,
717
+ disabled = false,
718
+ swrOptions
719
+ }) {
715
720
  const { client, locale, cartCookieAdapter } = useShopify();
716
721
  const updateAttributes = react.useCallback(
717
722
  async (_key, { arg }) => {
723
+ if (disabled || !cartCookieAdapter?.getCartId(locale)) {
724
+ return void 0;
725
+ }
718
726
  const updatedCart = await shopifySdk.updateCartAttributes(client, {
719
727
  ...arg,
720
728
  metafieldIdentifiers,
721
729
  cookieAdapter: cartCookieAdapter
722
730
  });
723
- console.log("useUpdateCartAttributes updatedCart", updatedCart);
724
731
  if (updatedCart) {
725
732
  mutate(updatedCart);
726
733
  }
727
734
  return updatedCart;
728
735
  },
729
- [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
736
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers, disabled]
730
737
  );
731
- return useSWRMutation8__default.default("update-cart-attributes", updateAttributes, options);
738
+ return useSWRMutation8__default.default("update-cart-attributes", updateAttributes, swrOptions);
732
739
  }
733
740
  function useHasPlusMemberInCart({
734
741
  memberSetting,
@@ -856,7 +863,7 @@ var useCartAttributes = ({
856
863
  })
857
864
  }
858
865
  ] : [];
859
- }, [cart]);
866
+ }, [cart, customer]);
860
867
  const presellAttributes = react.useMemo(() => {
861
868
  return [
862
869
  {
@@ -920,9 +927,7 @@ var useCartAttributes = ({
920
927
  "_play_mode_id",
921
928
  "_popup"
922
929
  ];
923
- return cart?.customAttributes?.filter(
924
- (item) => !commonAttributeKeys.includes(item.key)
925
- ) || [];
930
+ return cart?.customAttributes?.filter((item) => !commonAttributeKeys.includes(item.key)) || [];
926
931
  }, [cart]);
927
932
  return react.useMemo(
928
933
  () => ({
@@ -1084,8 +1089,9 @@ var createInitialValue = () => ({
1084
1089
  tddCoupon: void 0,
1085
1090
  isLoadingCoupon: false
1086
1091
  },
1087
- selectedPlusMemberProduct: null,
1088
- plusMemberProducts: [],
1092
+ selectedPlusMemberVariant: void 0,
1093
+ monthlyVariant: void 0,
1094
+ annualVariant: void 0,
1089
1095
  showPlusMemberBenefit: false,
1090
1096
  setShowPlusMemberBenefit: () => {
1091
1097
  },
@@ -1138,7 +1144,11 @@ function CartProvider({
1138
1144
  refreshDeps: [locale]
1139
1145
  }
1140
1146
  );
1141
- const { trigger: updateAttributes } = useUpdateCartAttributes(mutateCart, metafieldIdentifiers);
1147
+ const { trigger: updateAttributes } = useUpdateCartAttributes({
1148
+ mutate: mutateCart,
1149
+ metafieldIdentifiers,
1150
+ disabled: isCartLoading
1151
+ });
1142
1152
  const { attributes } = useCartAttributes({ profile, customer, cart, memberSetting });
1143
1153
  ahooks.useRequest(
1144
1154
  () => {