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

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
@@ -446,7 +446,6 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
446
446
  }
447
447
  return cart;
448
448
  }, [lines, cart]);
449
- console.log("effectiveCart useCalcAutoFreeGift", effectiveCart);
450
449
  const { activeCampaign, subtotal } = react.useMemo(() => {
451
450
  for (const campaign of autoFreeGiftConfig) {
452
451
  const { rule_conditions = [], rule_result } = campaign;
@@ -462,7 +461,6 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
462
461
  all_store_variant: spend_get_reward.main_product?.all_store_variant || false
463
462
  }
464
463
  );
465
- console.log("matchedSubtotal useCalcAutoFreeGift", matchedSubtotal);
466
464
  if (matchedSubtotal > 0) {
467
465
  return { activeCampaign: campaign, subtotal: matchedSubtotal };
468
466
  }
@@ -980,7 +978,7 @@ function useApplyCartCodes(options) {
980
978
  }
981
979
  return updatedCart;
982
980
  },
983
- [client, locale, cartCookieAdapter, mutateCart, cart]
981
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
984
982
  );
985
983
  return useSWRMutation__default.default("apply-codes", applyCodes, options);
986
984
  }
@@ -1004,7 +1002,7 @@ function useRemoveCartCodes(options) {
1004
1002
  }
1005
1003
  return updatedCart;
1006
1004
  },
1007
- [client, locale, cartCookieAdapter, mutateCart, cart]
1005
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
1008
1006
  );
1009
1007
  return useSWRMutation__default.default("remove-codes", removeCodes, options);
1010
1008
  }
@@ -1161,9 +1159,10 @@ function useUpdateCartLines(options) {
1161
1159
  if (updatedCart) {
1162
1160
  mutateCart(updatedCart);
1163
1161
  }
1162
+ console.log("use-update-cart-lines updatedCart", metafieldIdentifiers, updatedCart);
1164
1163
  return updatedCart;
1165
1164
  },
1166
- [client, locale, cartCookieAdapter, mutateCart]
1165
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1167
1166
  );
1168
1167
  return useSWRMutation__default.default("update-cart-lines", updateLines, options);
1169
1168
  }
@@ -1202,7 +1201,7 @@ function useRemoveCartLines(options) {
1202
1201
  }
1203
1202
  return updatedCart;
1204
1203
  },
1205
- [client, locale, cartCookieAdapter, mutateCart]
1204
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1206
1205
  );
1207
1206
  return useSWRMutation__default.default("remove-cart-lines", removeLines, options);
1208
1207
  }
@@ -1221,7 +1220,7 @@ function useUpdateCartAttributes(mutate, metafieldIdentifiers, options) {
1221
1220
  }
1222
1221
  return updatedCart;
1223
1222
  },
1224
- [client, locale, cartCookieAdapter, mutate]
1223
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
1225
1224
  );
1226
1225
  return useSWRMutation__default.default("update-cart-attributes", updateAttributes, options);
1227
1226
  }
@@ -1362,7 +1361,7 @@ var useCalcOrderDiscount = (cart, orderDiscountConfig, customer) => {
1362
1361
  const isCustomerLoading = react.useMemo(() => !customer ? true : false, [customer]);
1363
1362
  const dealsType = "";
1364
1363
  const { activeCampaign, subtotal } = react.useMemo(() => {
1365
- for (const campaign of orderDiscountConfig) {
1364
+ for (const campaign of orderDiscountConfig || []) {
1366
1365
  const { rule_conditions = [], result_detail } = campaign;
1367
1366
  const { main_product, order_discount_conf } = result_detail || {};
1368
1367
  const isPreCheckPassed = preCheck(rule_conditions, tags, []);
@@ -1466,7 +1465,7 @@ function useHasPlusMemberInCart({
1466
1465
  }, [cart?.lineItems, plus_monthly_product, plus_annual_product]);
1467
1466
  }
1468
1467
  var getReferralAttributes = () => {
1469
- const inviteCode = shopifySdk.getLocalStorage("invite_code") || Cookies5__default.default.get("invite_code");
1468
+ const inviteCode = shopifySdk.getLocalStorage("inviteCode") || Cookies5__default.default.get("inviteCode");
1470
1469
  const playModeId = shopifySdk.getLocalStorage("playModeId") || Cookies5__default.default.get("playModeId");
1471
1470
  const popup = shopifySdk.getLocalStorage("_popup") || Cookies5__default.default.get("_popup");
1472
1471
  if (inviteCode && playModeId) {
@@ -2777,7 +2776,7 @@ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
2777
2776
  }
2778
2777
  return updatedCart;
2779
2778
  },
2780
- [client, locale, cartCookieAdapter, mutate]
2779
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
2781
2780
  );
2782
2781
  return useSWRMutation__default.default("update-cart-delivery-options", updateDeliveryOptions, options);
2783
2782
  }
@@ -3276,7 +3275,8 @@ function CartProvider({
3276
3275
  cart,
3277
3276
  mutateCart,
3278
3277
  isCartLoading: isCartLoading || isCodeChanging,
3279
- setLoadingState
3278
+ setLoadingState,
3279
+ metafieldIdentifiers
3280
3280
  });
3281
3281
  const removeCustomAttributes = react.useCallback(
3282
3282
  (attributes2) => {
@@ -3417,9 +3417,9 @@ function CartProvider({
3417
3417
  );
3418
3418
  return /* @__PURE__ */ jsxRuntime.jsx(CartContext.Provider, { value, children });
3419
3419
  }
3420
- function useCartContext() {
3420
+ function useCartContext(options) {
3421
3421
  const context = react.useContext(CartContext);
3422
- if (!context) {
3422
+ if (!context && !options?.optional) {
3423
3423
  throw new Error("useCartContext must be used within a CartProvider");
3424
3424
  }
3425
3425
  return context;