@anker-in/shopify-react 1.2.0-beta.4 → 1.2.0-beta.5

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.
@@ -141,6 +141,8 @@ interface CartProviderProps {
141
141
  memberSetting?: PlusMemberSettingsMetafields;
142
142
  /** App context */
143
143
  appContext?: AppContext;
144
+ /** 是否禁用自动更新 line item 的 code amount attributes,默认为 false */
145
+ disableUpdateLineCodeAmountAttributes?: boolean;
144
146
  }
145
147
  /**
146
148
  * Cart Provider Component
@@ -162,7 +164,7 @@ interface CartProviderProps {
162
164
  * </ShopifyProvider>
163
165
  * ```
164
166
  */
165
- declare function CartProvider({ children, functionAutoFreeGiftConfig, scriptAutoFreeGiftConfig, profile, customer, locale, metafieldIdentifiers, memberSetting, appContext, }: CartProviderProps): react_jsx_runtime.JSX.Element;
167
+ declare function CartProvider({ children, functionAutoFreeGiftConfig, scriptAutoFreeGiftConfig, profile, customer, locale, metafieldIdentifiers, memberSetting, appContext, disableUpdateLineCodeAmountAttributes, }: CartProviderProps): react_jsx_runtime.JSX.Element;
166
168
  /**
167
169
  * Hook to access cart context
168
170
  *
@@ -141,6 +141,8 @@ interface CartProviderProps {
141
141
  memberSetting?: PlusMemberSettingsMetafields;
142
142
  /** App context */
143
143
  appContext?: AppContext;
144
+ /** 是否禁用自动更新 line item 的 code amount attributes,默认为 false */
145
+ disableUpdateLineCodeAmountAttributes?: boolean;
144
146
  }
145
147
  /**
146
148
  * Cart Provider Component
@@ -162,7 +164,7 @@ interface CartProviderProps {
162
164
  * </ShopifyProvider>
163
165
  * ```
164
166
  */
165
- declare function CartProvider({ children, functionAutoFreeGiftConfig, scriptAutoFreeGiftConfig, profile, customer, locale, metafieldIdentifiers, memberSetting, appContext, }: CartProviderProps): react_jsx_runtime.JSX.Element;
167
+ declare function CartProvider({ children, functionAutoFreeGiftConfig, scriptAutoFreeGiftConfig, profile, customer, locale, metafieldIdentifiers, memberSetting, appContext, disableUpdateLineCodeAmountAttributes, }: CartProviderProps): react_jsx_runtime.JSX.Element;
166
168
  /**
167
169
  * Hook to access cart context
168
170
  *
@@ -972,7 +972,8 @@ var useUpdateLineCodeAmountAttributes = ({
972
972
  mutateCart,
973
973
  isCartLoading,
974
974
  setLoadingState,
975
- metafieldIdentifiers
975
+ metafieldIdentifiers,
976
+ disabled = false
976
977
  }) => {
977
978
  const { client, cartCookieAdapter } = useShopify();
978
979
  const mainProductDiscountCodes = react.useMemo(
@@ -1050,7 +1051,7 @@ var useUpdateLineCodeAmountAttributes = ({
1050
1051
  );
1051
1052
  const { loading } = ahooks.useRequest(
1052
1053
  async () => {
1053
- if (linesNeedUpdate?.length && !isCartLoading) {
1054
+ if (linesNeedUpdate?.length && !isCartLoading && !disabled) {
1054
1055
  const result = await shopifySdk.updateCartLines(client, {
1055
1056
  cartId: cart?.id || "",
1056
1057
  lines: linesNeedUpdate,
@@ -1066,7 +1067,7 @@ var useUpdateLineCodeAmountAttributes = ({
1066
1067
  throttleWait: 3e3,
1067
1068
  // 3 秒内只触发最后一次更新
1068
1069
  throttleTrailing: true,
1069
- refreshDeps: [linesNeedUpdate, isCartLoading]
1070
+ refreshDeps: [linesNeedUpdate, isCartLoading, disabled]
1070
1071
  }
1071
1072
  );
1072
1073
  react.useEffect(() => {
@@ -1185,7 +1186,8 @@ function CartProvider({
1185
1186
  locale,
1186
1187
  metafieldIdentifiers,
1187
1188
  memberSetting,
1188
- appContext
1189
+ appContext,
1190
+ disableUpdateLineCodeAmountAttributes = false
1189
1191
  }) {
1190
1192
  const { client, cartCookieAdapter } = useShopify();
1191
1193
  const [customAttributes, setCustomAttributes] = react.useState([]);
@@ -1266,7 +1268,8 @@ function CartProvider({
1266
1268
  mutateCart,
1267
1269
  isCartLoading: isCartLoading || isCodeChanging,
1268
1270
  setLoadingState,
1269
- metafieldIdentifiers
1271
+ metafieldIdentifiers,
1272
+ disabled: disableUpdateLineCodeAmountAttributes
1270
1273
  });
1271
1274
  const removeCustomAttributes = react.useCallback(
1272
1275
  (attributes) => {