@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.mjs CHANGED
@@ -972,7 +972,7 @@ function useApplyCartCodes(options) {
972
972
  }
973
973
  return updatedCart;
974
974
  },
975
- [client, locale, cartCookieAdapter, mutateCart, cart]
975
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
976
976
  );
977
977
  return useSWRMutation("apply-codes", applyCodes, options);
978
978
  }
@@ -996,7 +996,7 @@ function useRemoveCartCodes(options) {
996
996
  }
997
997
  return updatedCart;
998
998
  },
999
- [client, locale, cartCookieAdapter, mutateCart, cart]
999
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
1000
1000
  );
1001
1001
  return useSWRMutation("remove-codes", removeCodes, options);
1002
1002
  }
@@ -1153,9 +1153,10 @@ function useUpdateCartLines(options) {
1153
1153
  if (updatedCart) {
1154
1154
  mutateCart(updatedCart);
1155
1155
  }
1156
+ console.log("use-update-cart-lines updatedCart", metafieldIdentifiers, updatedCart);
1156
1157
  return updatedCart;
1157
1158
  },
1158
- [client, locale, cartCookieAdapter, mutateCart]
1159
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1159
1160
  );
1160
1161
  return useSWRMutation("update-cart-lines", updateLines, options);
1161
1162
  }
@@ -1194,7 +1195,7 @@ function useRemoveCartLines(options) {
1194
1195
  }
1195
1196
  return updatedCart;
1196
1197
  },
1197
- [client, locale, cartCookieAdapter, mutateCart]
1198
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1198
1199
  );
1199
1200
  return useSWRMutation("remove-cart-lines", removeLines, options);
1200
1201
  }
@@ -1213,7 +1214,7 @@ function useUpdateCartAttributes(mutate, metafieldIdentifiers, options) {
1213
1214
  }
1214
1215
  return updatedCart;
1215
1216
  },
1216
- [client, locale, cartCookieAdapter, mutate]
1217
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
1217
1218
  );
1218
1219
  return useSWRMutation("update-cart-attributes", updateAttributes, options);
1219
1220
  }
@@ -1354,7 +1355,7 @@ var useCalcOrderDiscount = (cart, orderDiscountConfig, customer) => {
1354
1355
  const isCustomerLoading = useMemo(() => !customer ? true : false, [customer]);
1355
1356
  const dealsType = "";
1356
1357
  const { activeCampaign, subtotal } = useMemo(() => {
1357
- for (const campaign of orderDiscountConfig) {
1358
+ for (const campaign of orderDiscountConfig || []) {
1358
1359
  const { rule_conditions = [], result_detail } = campaign;
1359
1360
  const { main_product, order_discount_conf } = result_detail || {};
1360
1361
  const isPreCheckPassed = preCheck(rule_conditions, tags, []);
@@ -1458,7 +1459,7 @@ function useHasPlusMemberInCart({
1458
1459
  }, [cart?.lineItems, plus_monthly_product, plus_annual_product]);
1459
1460
  }
1460
1461
  var getReferralAttributes = () => {
1461
- const inviteCode = getLocalStorage("invite_code") || Cookies5.get("invite_code");
1462
+ const inviteCode = getLocalStorage("inviteCode") || Cookies5.get("inviteCode");
1462
1463
  const playModeId = getLocalStorage("playModeId") || Cookies5.get("playModeId");
1463
1464
  const popup = getLocalStorage("_popup") || Cookies5.get("_popup");
1464
1465
  if (inviteCode && playModeId) {
@@ -2769,7 +2770,7 @@ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
2769
2770
  }
2770
2771
  return updatedCart;
2771
2772
  },
2772
- [client, locale, cartCookieAdapter, mutate]
2773
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
2773
2774
  );
2774
2775
  return useSWRMutation("update-cart-delivery-options", updateDeliveryOptions, options);
2775
2776
  }
@@ -3409,9 +3410,9 @@ function CartProvider({
3409
3410
  );
3410
3411
  return /* @__PURE__ */ jsx(CartContext.Provider, { value, children });
3411
3412
  }
3412
- function useCartContext() {
3413
+ function useCartContext(options) {
3413
3414
  const context = useContext(CartContext);
3414
- if (!context) {
3415
+ if (!context && !options?.optional) {
3415
3416
  throw new Error("useCartContext must be used within a CartProvider");
3416
3417
  }
3417
3418
  return context;