@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.
@@ -702,24 +702,31 @@ var useScriptAutoFreeGift = ({
702
702
  giftProductsResult: finalGiftProductsResult
703
703
  };
704
704
  };
705
- function useUpdateCartAttributes(mutate, metafieldIdentifiers, options) {
705
+ function useUpdateCartAttributes({
706
+ mutate,
707
+ metafieldIdentifiers,
708
+ disabled = false,
709
+ swrOptions
710
+ }) {
706
711
  const { client, locale, cartCookieAdapter } = useShopify();
707
712
  const updateAttributes = useCallback(
708
713
  async (_key, { arg }) => {
714
+ if (disabled || !cartCookieAdapter?.getCartId(locale)) {
715
+ return void 0;
716
+ }
709
717
  const updatedCart = await updateCartAttributes(client, {
710
718
  ...arg,
711
719
  metafieldIdentifiers,
712
720
  cookieAdapter: cartCookieAdapter
713
721
  });
714
- console.log("useUpdateCartAttributes updatedCart", updatedCart);
715
722
  if (updatedCart) {
716
723
  mutate(updatedCart);
717
724
  }
718
725
  return updatedCart;
719
726
  },
720
- [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
727
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers, disabled]
721
728
  );
722
- return useSWRMutation8("update-cart-attributes", updateAttributes, options);
729
+ return useSWRMutation8("update-cart-attributes", updateAttributes, swrOptions);
723
730
  }
724
731
  function useHasPlusMemberInCart({
725
732
  memberSetting,
@@ -847,7 +854,7 @@ var useCartAttributes = ({
847
854
  })
848
855
  }
849
856
  ] : [];
850
- }, [cart]);
857
+ }, [cart, customer]);
851
858
  const presellAttributes = useMemo(() => {
852
859
  return [
853
860
  {
@@ -911,9 +918,7 @@ var useCartAttributes = ({
911
918
  "_play_mode_id",
912
919
  "_popup"
913
920
  ];
914
- return cart?.customAttributes?.filter(
915
- (item) => !commonAttributeKeys.includes(item.key)
916
- ) || [];
921
+ return cart?.customAttributes?.filter((item) => !commonAttributeKeys.includes(item.key)) || [];
917
922
  }, [cart]);
918
923
  return useMemo(
919
924
  () => ({
@@ -1075,8 +1080,9 @@ var createInitialValue = () => ({
1075
1080
  tddCoupon: void 0,
1076
1081
  isLoadingCoupon: false
1077
1082
  },
1078
- selectedPlusMemberProduct: null,
1079
- plusMemberProducts: [],
1083
+ selectedPlusMemberVariant: void 0,
1084
+ monthlyVariant: void 0,
1085
+ annualVariant: void 0,
1080
1086
  showPlusMemberBenefit: false,
1081
1087
  setShowPlusMemberBenefit: () => {
1082
1088
  },
@@ -1129,7 +1135,11 @@ function CartProvider({
1129
1135
  refreshDeps: [locale]
1130
1136
  }
1131
1137
  );
1132
- const { trigger: updateAttributes } = useUpdateCartAttributes(mutateCart, metafieldIdentifiers);
1138
+ const { trigger: updateAttributes } = useUpdateCartAttributes({
1139
+ mutate: mutateCart,
1140
+ metafieldIdentifiers,
1141
+ disabled: isCartLoading
1142
+ });
1133
1143
  const { attributes } = useCartAttributes({ profile, customer, cart, memberSetting });
1134
1144
  useRequest(
1135
1145
  () => {