@anker-in/shopify-react 0.1.1-beta.30 → 0.1.1-beta.31

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/dist/index.js CHANGED
@@ -980,7 +980,7 @@ function useApplyCartCodes(options) {
980
980
  }
981
981
  return updatedCart;
982
982
  },
983
- [client, locale, cartCookieAdapter, mutateCart, cart]
983
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
984
984
  );
985
985
  return useSWRMutation__default.default("apply-codes", applyCodes, options);
986
986
  }
@@ -1004,7 +1004,7 @@ function useRemoveCartCodes(options) {
1004
1004
  }
1005
1005
  return updatedCart;
1006
1006
  },
1007
- [client, locale, cartCookieAdapter, mutateCart, cart]
1007
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
1008
1008
  );
1009
1009
  return useSWRMutation__default.default("remove-codes", removeCodes, options);
1010
1010
  }
@@ -1161,9 +1161,10 @@ function useUpdateCartLines(options) {
1161
1161
  if (updatedCart) {
1162
1162
  mutateCart(updatedCart);
1163
1163
  }
1164
+ console.log("use-update-cart-lines updatedCart", metafieldIdentifiers, updatedCart);
1164
1165
  return updatedCart;
1165
1166
  },
1166
- [client, locale, cartCookieAdapter, mutateCart]
1167
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1167
1168
  );
1168
1169
  return useSWRMutation__default.default("update-cart-lines", updateLines, options);
1169
1170
  }
@@ -1202,7 +1203,7 @@ function useRemoveCartLines(options) {
1202
1203
  }
1203
1204
  return updatedCart;
1204
1205
  },
1205
- [client, locale, cartCookieAdapter, mutateCart]
1206
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1206
1207
  );
1207
1208
  return useSWRMutation__default.default("remove-cart-lines", removeLines, options);
1208
1209
  }
@@ -1221,7 +1222,7 @@ function useUpdateCartAttributes(mutate, metafieldIdentifiers, options) {
1221
1222
  }
1222
1223
  return updatedCart;
1223
1224
  },
1224
- [client, locale, cartCookieAdapter, mutate]
1225
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
1225
1226
  );
1226
1227
  return useSWRMutation__default.default("update-cart-attributes", updateAttributes, options);
1227
1228
  }
@@ -1362,7 +1363,7 @@ var useCalcOrderDiscount = (cart, orderDiscountConfig, customer) => {
1362
1363
  const isCustomerLoading = react.useMemo(() => !customer ? true : false, [customer]);
1363
1364
  const dealsType = "";
1364
1365
  const { activeCampaign, subtotal } = react.useMemo(() => {
1365
- for (const campaign of orderDiscountConfig) {
1366
+ for (const campaign of orderDiscountConfig || []) {
1366
1367
  const { rule_conditions = [], result_detail } = campaign;
1367
1368
  const { main_product, order_discount_conf } = result_detail || {};
1368
1369
  const isPreCheckPassed = preCheck(rule_conditions, tags, []);
@@ -1466,7 +1467,7 @@ function useHasPlusMemberInCart({
1466
1467
  }, [cart?.lineItems, plus_monthly_product, plus_annual_product]);
1467
1468
  }
1468
1469
  var getReferralAttributes = () => {
1469
- const inviteCode = shopifySdk.getLocalStorage("invite_code") || Cookies5__default.default.get("invite_code");
1470
+ const inviteCode = shopifySdk.getLocalStorage("inviteCode") || Cookies5__default.default.get("inviteCode");
1470
1471
  const playModeId = shopifySdk.getLocalStorage("playModeId") || Cookies5__default.default.get("playModeId");
1471
1472
  const popup = shopifySdk.getLocalStorage("_popup") || Cookies5__default.default.get("_popup");
1472
1473
  if (inviteCode && playModeId) {
@@ -2777,7 +2778,7 @@ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
2777
2778
  }
2778
2779
  return updatedCart;
2779
2780
  },
2780
- [client, locale, cartCookieAdapter, mutate]
2781
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
2781
2782
  );
2782
2783
  return useSWRMutation__default.default("update-cart-delivery-options", updateDeliveryOptions, options);
2783
2784
  }
@@ -3417,9 +3418,9 @@ function CartProvider({
3417
3418
  );
3418
3419
  return /* @__PURE__ */ jsxRuntime.jsx(CartContext.Provider, { value, children });
3419
3420
  }
3420
- function useCartContext() {
3421
+ function useCartContext(options) {
3421
3422
  const context = react.useContext(CartContext);
3422
- if (!context) {
3423
+ if (!context && !options?.optional) {
3423
3424
  throw new Error("useCartContext must be used within a CartProvider");
3424
3425
  }
3425
3426
  return context;