@anker-in/shopify-react 0.1.1-beta.4 → 0.1.1-beta.41

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
@@ -5,6 +5,7 @@ var shopifySdk = require('@anker-in/shopify-sdk');
5
5
  var Cookies5 = require('js-cookie');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var Decimal2 = require('decimal.js');
8
+ var shopifyCore = require('@anker-in/shopify-core');
8
9
  var useSWR = require('swr');
9
10
  var useSWRMutation = require('swr/mutation');
10
11
  var ahooks = require('ahooks');
@@ -53,6 +54,20 @@ var browserCartCookieAdapter = {
53
54
  Cookies5__default.default.remove(getCartCookieName(locale));
54
55
  }
55
56
  };
57
+
58
+ // src/adapters/browser-performance.ts
59
+ var BrowserPerformanceAdapter = class {
60
+ /**
61
+ * Start tracking a performance event
62
+ */
63
+ addToCartStart() {
64
+ }
65
+ /**
66
+ * End tracking a performance event
67
+ */
68
+ addToCartEnd() {
69
+ }
70
+ };
56
71
  function ShopifyProvider({
57
72
  config,
58
73
  locale,
@@ -61,7 +76,8 @@ function ShopifyProvider({
61
76
  cartCookieAdapter = browserCartCookieAdapter,
62
77
  routerAdapter,
63
78
  userAdapter,
64
- children
79
+ children,
80
+ performanceAdapter
65
81
  }) {
66
82
  const client = react.useMemo(() => {
67
83
  return shopifySdk.createShopifyClient(config, locale);
@@ -75,7 +91,8 @@ function ShopifyProvider({
75
91
  cookieAdapter,
76
92
  cartCookieAdapter,
77
93
  routerAdapter,
78
- userAdapter
94
+ userAdapter,
95
+ performanceAdapter
79
96
  };
80
97
  }, [
81
98
  client,
@@ -85,6 +102,7 @@ function ShopifyProvider({
85
102
  cookieAdapter,
86
103
  cartCookieAdapter,
87
104
  routerAdapter,
105
+ performanceAdapter,
88
106
  userAdapter
89
107
  ]);
90
108
  return /* @__PURE__ */ jsxRuntime.jsx(ShopifyContext.Provider, { value, children });
@@ -140,6 +158,7 @@ var CUSTOMER_ATTRIBUTE_KEY = "_discounts_function_env";
140
158
  var CUSTOMER_SCRIPT_GIFT_KEY = "_giveaway_gradient_gifts";
141
159
  var CODE_AMOUNT_KEY = "_sku_code_money";
142
160
  var SCRIPT_CODE_AMOUNT_KEY = "_code_money";
161
+ var MEMBER_PRICE_ATTRIBUTE_KEY = "_member_price";
143
162
  var MAIN_PRODUCT_CODE = ["WS24", "WSTD", "WS7D", "WSCP", "WSPE", "WSPD"];
144
163
 
145
164
  // src/hooks/cart/utils/normalize-add-to-cart-lines.ts
@@ -148,9 +167,10 @@ function normalizeAddToCartLines(lines) {
148
167
  const variant = line.variant;
149
168
  const product = variant.product;
150
169
  const quantity = line.quantity || 1;
151
- const price = variant.finalPrice?.amount ? Number(variant.finalPrice.amount) : variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : variant.price?.amount ? Number(variant.price.amount) : 0;
152
- const subtotalAmount = price * quantity;
153
- const totalAmount = subtotalAmount;
170
+ const originalPrice = variant.price?.amount ? Number(variant.price.amount) : 0;
171
+ const finalPrice = variant.finalPrice?.amount === void 0 ? originalPrice : Number(variant.finalPrice?.amount);
172
+ const subtotalAmount = originalPrice * quantity;
173
+ const totalAmount = finalPrice * quantity;
154
174
  return {
155
175
  id: `temp-line-${index}-${variant.id}`,
156
176
  // Temporary ID for pre-cart lines
@@ -164,7 +184,7 @@ function normalizeAddToCartLines(lines) {
164
184
  customAttributes: line.attributes || [],
165
185
  variant: {
166
186
  id: variant.id,
167
- price,
187
+ price: finalPrice,
168
188
  listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
169
189
  sku: variant.sku || "",
170
190
  name: variant.title || "",
@@ -195,15 +215,16 @@ function createMockCartFromLines(lines, existingCart) {
195
215
  const normalizedLines = normalizeAddToCartLines(lines);
196
216
  const subtotalPrice = normalizedLines.reduce((sum, line) => sum + line.subtotalAmount, 0);
197
217
  const totalPrice = normalizedLines.reduce((sum, line) => sum + line.totalAmount, 0);
218
+ const currency = lines[0]?.variant?.price?.currencyCode;
198
219
  return {
199
220
  id: existingCart?.id || "temp-cart-id",
200
221
  customerId: existingCart?.customerId,
201
222
  email: existingCart?.email,
202
223
  createdAt: existingCart?.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
203
- currency: existingCart?.currency || { code: "USD" },
224
+ currency: existingCart?.currency || { code: currency },
204
225
  taxesIncluded: existingCart?.taxesIncluded,
205
226
  lineItems: normalizedLines,
206
- totallineItemsDiscount: 0,
227
+ totalLineItemsDiscount: 0,
207
228
  orderDiscounts: 0,
208
229
  lineItemsSubtotalPrice: subtotalPrice,
209
230
  subtotalPrice,
@@ -234,22 +255,12 @@ var getQuery = () => {
234
255
  }
235
256
  return theRequest;
236
257
  };
237
- function atobID(id) {
238
- if (id && typeof id === "string" && id.includes("/")) {
239
- return id.split("/").pop()?.split("?")?.shift();
240
- } else {
241
- return id;
242
- }
243
- }
244
- function btoaID(id, type = "ProductVariant") {
245
- return `gid://shopify/${type}/${id}`;
246
- }
247
258
  var getMatchedMainProductSubTotal = (cartData, variant_list, main_product) => {
248
259
  const isAllStoreVariant = main_product?.all_store_variant ?? false;
249
260
  const matchedList = cartData?.lineItems?.filter((line) => {
250
261
  const { is_gift } = getDiscountEnvAttributeValue(line.customAttributes);
251
262
  return isAllStoreVariant ? !is_gift : variant_list?.find((item) => {
252
- return !is_gift && atobID(line.variantId) === item;
263
+ return !is_gift && shopifyCore.atobID(line.variantId) === item;
253
264
  });
254
265
  });
255
266
  return matchedList?.reduce((acc, line) => {
@@ -475,43 +486,29 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
475
486
  }
476
487
  return { activeCampaign: null, subtotal: 0 };
477
488
  }, [autoFreeGiftConfig, effectiveCart, tags, dealsType]);
478
- const { qualifyingGift, nextTierGoal } = react.useMemo(() => {
489
+ const { qualifyingTier, nextTierGoal, actualThreshold, currentCurrency } = react.useMemo(() => {
479
490
  if (!activeCampaign || !activeCampaign.rule_result?.spend_get_reward?.gift_product) {
480
- return { qualifyingGift: null, nextTierGoal: null };
491
+ return { qualifyingTier: null, nextTierGoal: null, actualThreshold: 0, currentCurrency: "" };
481
492
  }
482
493
  const giftTiers = activeCampaign.rule_result.spend_get_reward.gift_product;
483
- const qualifyingTier = [...giftTiers].sort((a, b) => Number(b.spend_sum_money) - Number(a.spend_sum_money)).find((tier) => subtotal >= Number(tier.spend_sum_money));
484
- const nextGoal = giftTiers.find((tier) => subtotal < Number(tier.spend_sum_money));
485
- if (!qualifyingTier) {
486
- return { qualifyingGift: null, nextTierGoal: nextGoal || null };
487
- }
488
- const formattedGift = {
489
- tier: qualifyingTier,
490
- itemsToAdd: qualifyingTier.reward_list?.map((reward) => {
491
- const giftProduct = reward?.variant_list?.[0];
492
- if (!giftProduct) return null;
493
- return {
494
- variant: {
495
- id: btoaID(giftProduct.variant_id),
496
- handle: giftProduct.handle,
497
- sku: giftProduct.sku
498
- },
499
- quantity: reward?.get_unit || 1,
500
- attributes: [
501
- {
502
- key: CUSTOMER_ATTRIBUTE_KEY,
503
- value: JSON.stringify({
504
- is_gift: true,
505
- rule_id: activeCampaign.rule_id,
506
- spend_sum_money: qualifyingTier.spend_sum_money
507
- })
508
- }
509
- ]
510
- };
511
- }).filter((item) => item !== null)
494
+ const currentCurrency2 = effectiveCart?.currency?.code || "";
495
+ console.log("currentCurrency useCalcAutoFreeGift", effectiveCart, currentCurrency2);
496
+ const getThresholdAmount = (tier) => {
497
+ if (tier.spend_sum_money_multi_markets?.[currentCurrency2]?.value) {
498
+ return Number(tier.spend_sum_money_multi_markets[currentCurrency2].value);
499
+ }
500
+ return Number(tier.spend_sum_money || 0);
512
501
  };
513
- return { qualifyingGift: formattedGift, nextTierGoal: nextGoal || null };
514
- }, [activeCampaign, subtotal]);
502
+ const qualifyingTier2 = [...giftTiers].sort((a, b) => getThresholdAmount(b) - getThresholdAmount(a)).find((tier) => subtotal >= getThresholdAmount(tier));
503
+ const nextGoal = giftTiers.find((tier) => subtotal < getThresholdAmount(tier));
504
+ const actualThreshold2 = qualifyingTier2 ? getThresholdAmount(qualifyingTier2) : 0;
505
+ return {
506
+ qualifyingTier: qualifyingTier2,
507
+ nextTierGoal: nextGoal || null,
508
+ actualThreshold: actualThreshold2,
509
+ currentCurrency: currentCurrency2
510
+ };
511
+ }, [activeCampaign, subtotal, effectiveCart]);
515
512
  const giftHandles = react.useMemo(() => {
516
513
  const giftVariant = autoFreeGiftConfig.map(
517
514
  (item) => item.rule_result?.spend_get_reward?.gift_product?.map(
@@ -527,24 +524,82 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
527
524
  }
528
525
  return true;
529
526
  }, [giftHandles]);
530
- const { data: giftProductsResult } = useSWR__default.default(shouldFetch ? giftHandles : null, async () => {
531
- const res = await shopifySdk.getProductsByHandles(client, {
532
- handles: giftHandles,
533
- locale
534
- });
535
- const result = Array.isArray(res) ? res : [];
536
- giftProductsCache.current = {
537
- data: result,
538
- giftHandles: [...giftHandles]
539
- };
540
- return result;
541
- });
527
+ const { data: giftProductsResult } = useSWR__default.default(
528
+ shouldFetch ? giftHandles : null,
529
+ async () => {
530
+ const res = await shopifySdk.getProductsByHandles(client, {
531
+ handles: giftHandles,
532
+ locale
533
+ });
534
+ const result = Array.isArray(res) ? res : [];
535
+ giftProductsCache.current = {
536
+ data: result,
537
+ giftHandles: [...giftHandles]
538
+ };
539
+ return result;
540
+ },
541
+ {
542
+ revalidateOnFocus: false
543
+ }
544
+ );
542
545
  const finalGiftProductsResult = react.useMemo(() => {
543
546
  if (giftProductsCache.current && !shouldFetch) {
544
547
  return giftProductsCache.current.data || void 0;
545
548
  }
546
549
  return giftProductsResult;
547
550
  }, [giftProductsResult, shouldFetch]);
551
+ const qualifyingGift = react.useMemo(() => {
552
+ if (!qualifyingTier || !activeCampaign) {
553
+ return null;
554
+ }
555
+ const itemsToAdd = qualifyingTier.reward_list?.map((reward) => {
556
+ if (!reward.variant_list || reward.variant_list.length === 0) {
557
+ return null;
558
+ }
559
+ let selectedGiftProduct = null;
560
+ for (const giftVariant of reward.variant_list) {
561
+ const productInfo = finalGiftProductsResult?.find(
562
+ (p) => p.handle === giftVariant.handle
563
+ );
564
+ if (productInfo) {
565
+ const variantInfo = productInfo.variants?.find((v) => v.sku === giftVariant.sku);
566
+ if (variantInfo?.availableForSale) {
567
+ selectedGiftProduct = giftVariant;
568
+ break;
569
+ }
570
+ }
571
+ }
572
+ if (!selectedGiftProduct) {
573
+ selectedGiftProduct = reward.variant_list[0];
574
+ }
575
+ return {
576
+ variant: {
577
+ id: shopifyCore.btoaID(selectedGiftProduct.variant_id),
578
+ handle: selectedGiftProduct.handle,
579
+ sku: selectedGiftProduct.sku
580
+ },
581
+ quantity: reward?.get_unit || 1,
582
+ attributes: [
583
+ {
584
+ key: CUSTOMER_ATTRIBUTE_KEY,
585
+ value: JSON.stringify({
586
+ is_gift: true,
587
+ rule_id: activeCampaign.rule_id,
588
+ spend_sum_money: actualThreshold,
589
+ // 使用实际的门槛金额(多币种支持)
590
+ currency_code: currentCurrency
591
+ // 记录当前币种
592
+ })
593
+ }
594
+ ]
595
+ };
596
+ }).filter((item) => item !== null);
597
+ const formattedGift = {
598
+ tier: qualifyingTier,
599
+ itemsToAdd
600
+ };
601
+ return formattedGift;
602
+ }, [qualifyingTier, activeCampaign, finalGiftProductsResult, actualThreshold, currentCurrency]);
548
603
  return {
549
604
  qualifyingGift,
550
605
  nextTierGoal,
@@ -591,12 +646,14 @@ var useScriptAutoFreeGift = ({
591
646
  upgrade_multiple2 = 1.2;
592
647
  upgrade_value2 = 40;
593
648
  }
594
- effectiveCart?.lineItems?.forEach(({ customAttributes }) => {
595
- customAttributes?.forEach(({ key, value }) => {
596
- if (key === "_amount_upgrade_multiple") upgrade_multiple2 = Number(value) || 1;
597
- if (key === "_amount_upgrade_value") upgrade_value2 = Number(value) || 0;
598
- });
599
- });
649
+ effectiveCart?.lineItems?.forEach(
650
+ ({ customAttributes }) => {
651
+ customAttributes?.forEach(({ key, value }) => {
652
+ if (key === "_amount_upgrade_multiple") upgrade_multiple2 = Number(value) || 1;
653
+ if (key === "_amount_upgrade_value") upgrade_value2 = Number(value) || 0;
654
+ });
655
+ }
656
+ );
600
657
  return [upgrade_multiple2, upgrade_value2];
601
658
  }, [effectiveCart?.lineItems, points_subscribe]);
602
659
  const breakpoints = react.useMemo(() => {
@@ -661,18 +718,24 @@ var useScriptAutoFreeGift = ({
661
718
  const nextLevel = levelIndex > 0 ? sortedLevels[levelIndex - 1] ?? null : null;
662
719
  return [currentLevel, nextLevel];
663
720
  }, [breakpoints, involvedSubTotal, involvedLines.length]);
664
- const { data: giftProductsResult } = useSWR__default.default(shouldFetch ? giftHandles : null, async () => {
665
- const res = await shopifySdk.getProductsByHandles(client, {
666
- handles: giftHandles,
667
- locale
668
- });
669
- const result = Array.isArray(res) ? res : [];
670
- giftProductsCache.current = {
671
- data: result,
672
- giftHandles: [...giftHandles]
673
- };
674
- return result;
675
- });
721
+ const { data: giftProductsResult } = useSWR__default.default(
722
+ shouldFetch ? giftHandles : null,
723
+ async () => {
724
+ const res = await shopifySdk.getProductsByHandles(client, {
725
+ handles: giftHandles,
726
+ locale
727
+ });
728
+ const result = Array.isArray(res) ? res : [];
729
+ giftProductsCache.current = {
730
+ data: result,
731
+ giftHandles: [...giftHandles]
732
+ };
733
+ return result;
734
+ },
735
+ {
736
+ revalidateOnFocus: false
737
+ }
738
+ );
676
739
  const finalGiftProductsResult = react.useMemo(() => {
677
740
  if (giftProductsCache.current && !shouldFetch) {
678
741
  return giftProductsCache.current.data || void 0;
@@ -739,11 +802,23 @@ function useAddCartLines(options) {
739
802
  const { mutateCart, metafieldIdentifiers } = useCartContext();
740
803
  const addLines = react.useCallback(
741
804
  async (_key, { arg }) => {
742
- let updatedCart = await shopifySdk.addCartLines(client, {
743
- ...arg,
744
- metafieldIdentifiers,
745
- cookieAdapter: cartCookieAdapter
746
- });
805
+ const { cartId, lines } = arg;
806
+ const id = cartId || cartCookieAdapter?.getCartId(locale);
807
+ let updatedCart;
808
+ if (!id) {
809
+ updatedCart = await shopifySdk.createCart(client, {
810
+ lines,
811
+ metafieldIdentifiers,
812
+ cookieAdapter: cartCookieAdapter
813
+ });
814
+ } else {
815
+ updatedCart = await shopifySdk.addCartLines(client, {
816
+ cartId: id,
817
+ lines,
818
+ metafieldIdentifiers,
819
+ cookieAdapter: cartCookieAdapter
820
+ });
821
+ }
747
822
  if (updatedCart) {
748
823
  const unApplicableCodes = updatedCart.discountCodes.filter((item) => !item.applicable).map((item) => item.code);
749
824
  if (unApplicableCodes.length > 0) {
@@ -790,7 +865,7 @@ var trackAddToCartGA = ({
790
865
  const currencyCode = variant.product?.price?.currencyCode;
791
866
  const totalPrice = lineItems?.reduce(
792
867
  (prev, { variant: variant2 }) => prev.plus(
793
- variant2?.finalPrice?.amount ?? variant2?.compareAtPrice?.amount ?? variant2?.price?.amount ?? 0
868
+ variant2?.finalPrice?.amount === void 0 ? Number(variant2?.price?.amount) || 0 : Number(variant2?.finalPrice?.amount) || 0
794
869
  ),
795
870
  new Decimal2__default.default(0)
796
871
  ).toNumber();
@@ -825,7 +900,7 @@ var trackBeginCheckoutGA = ({
825
900
  }
826
901
  const totalPrice = lineItems?.reduce(
827
902
  (prev, { variant }) => prev.plus(
828
- variant?.finalPrice?.amount ?? variant?.compareAtPrice?.amount ?? variant?.price?.amount ?? 0
903
+ variant?.finalPrice?.amount === void 0 ? Number(variant?.price?.amount) || 0 : Number(variant?.finalPrice?.amount) || 0
829
904
  ),
830
905
  new Decimal2__default.default(0)
831
906
  ).toNumber();
@@ -858,10 +933,10 @@ var trackBuyNowGA = ({
858
933
  return;
859
934
  }
860
935
  const { variant } = lineItems[0];
861
- const currencyCode = variant.price?.currencyCode;
936
+ const currencyCode = variant.product?.price?.currencyCode || variant.price?.currencyCode;
862
937
  const totalPrice = lineItems?.reduce(
863
938
  (prev, { variant: variant2 }) => prev.plus(
864
- variant2?.finalPrice?.amount ?? variant2?.compareAtPrice?.amount ?? (variant2?.price?.amount || 0)
939
+ variant2?.finalPrice?.amount === void 0 ? Number(variant2?.price?.amount) || 0 : Number(variant2?.finalPrice?.amount) || 0
865
940
  ),
866
941
  new Decimal2__default.default(0)
867
942
  ).toNumber();
@@ -935,7 +1010,7 @@ function useApplyCartCodes(options) {
935
1010
  if (!discountCodes?.length) {
936
1011
  throw new Error("Invalid input used for this operation: Miss discountCode");
937
1012
  }
938
- const cartId = providedCartId ? void 0 : providedCartId || cart?.id;
1013
+ const cartId = providedCartId || cart?.id;
939
1014
  if (!cartId) {
940
1015
  return void 0;
941
1016
  }
@@ -948,12 +1023,18 @@ function useApplyCartCodes(options) {
948
1023
  cookieAdapter: cartCookieAdapter,
949
1024
  metafieldIdentifiers
950
1025
  });
1026
+ const unApplicableCodes = discountCodes.filter(
1027
+ (code) => updatedCart?.discountCodes?.find((item) => item.code === code && !item.applicable)
1028
+ );
1029
+ if (unApplicableCodes.length) {
1030
+ throw new Error(`${unApplicableCodes.join(", ")} is not applicable to the cart`);
1031
+ }
951
1032
  if (updatedCart) {
952
1033
  mutateCart(updatedCart);
953
1034
  }
954
1035
  return updatedCart;
955
1036
  },
956
- [client, locale, cartCookieAdapter, mutateCart, cart]
1037
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
957
1038
  );
958
1039
  return useSWRMutation__default.default("apply-codes", applyCodes, options);
959
1040
  }
@@ -963,7 +1044,7 @@ function useRemoveCartCodes(options) {
963
1044
  const removeCodes = react.useCallback(
964
1045
  async (_key, { arg }) => {
965
1046
  const { cartId: providedCartId, discountCodes } = arg;
966
- const cartId = providedCartId ? void 0 : providedCartId || cart?.id;
1047
+ const cartId = providedCartId || cart?.id;
967
1048
  const codes = cart?.discountCodes?.filter((code) => !!code.applicable) || [];
968
1049
  const leftCodes = codes.filter((code) => discountCodes?.length ? !discountCodes.includes(code.code) : code.code).map((code) => code.code);
969
1050
  const updatedCart = await shopifySdk.updateCartCodes(client, {
@@ -977,18 +1058,105 @@ function useRemoveCartCodes(options) {
977
1058
  }
978
1059
  return updatedCart;
979
1060
  },
980
- [client, locale, cartCookieAdapter, mutateCart, cart]
1061
+ [client, locale, cartCookieAdapter, mutateCart, cart, metafieldIdentifiers]
981
1062
  );
982
1063
  return useSWRMutation__default.default("remove-codes", removeCodes, options);
983
1064
  }
1065
+ var initSameLinesAttributes = ({
1066
+ cart,
1067
+ line
1068
+ }) => {
1069
+ const sameLineInCart = cart?.lineItems.find(
1070
+ (lineInCart) => lineInCart.variant.sku === line.variant?.sku && lineInCart.product?.handle === line.variant?.product?.handle
1071
+ );
1072
+ const codeAmountAttribute = sameLineInCart?.customAttributes?.find(
1073
+ (attr) => attr.key === CODE_AMOUNT_KEY
1074
+ );
1075
+ const scriptCodeAmountAttribute = sameLineInCart?.customAttributes?.find(
1076
+ (attr) => attr.key === SCRIPT_CODE_AMOUNT_KEY
1077
+ );
1078
+ let functionAttribute = null;
1079
+ try {
1080
+ functionAttribute = sameLineInCart?.customAttributes?.find(
1081
+ (attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY && JSON.parse(attr.value)?.discounted_amount
1082
+ );
1083
+ } catch (error) {
1084
+ }
1085
+ if (codeAmountAttribute || functionAttribute || scriptCodeAmountAttribute) {
1086
+ return {
1087
+ ...line,
1088
+ attributes: [
1089
+ ...line.attributes || [],
1090
+ codeAmountAttribute,
1091
+ functionAttribute,
1092
+ scriptCodeAmountAttribute
1093
+ ].filter(Boolean)
1094
+ };
1095
+ }
1096
+ return line;
1097
+ };
1098
+ var initDiscountAttributes = ({ line }) => {
1099
+ let itemAttributes = line.attributes || [];
1100
+ const functionEnvAttribute = itemAttributes.find((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY);
1101
+ if (!functionEnvAttribute) {
1102
+ itemAttributes = itemAttributes.concat([
1103
+ {
1104
+ key: CUSTOMER_ATTRIBUTE_KEY,
1105
+ value: JSON.stringify({
1106
+ is_gift: false,
1107
+ discounted_amount: line.variant?.finalPrice?.amount === void 0 ? Number(line.variant?.price?.amount) * (line.quantity || 1) : Number(line.variant?.finalPrice?.amount) * (line.quantity || 1)
1108
+ })
1109
+ }
1110
+ ]);
1111
+ }
1112
+ const memberPriceAttribute = itemAttributes.find(
1113
+ (attr) => attr.key === MEMBER_PRICE_ATTRIBUTE_KEY
1114
+ );
1115
+ const coupon = line.coupon;
1116
+ if (!memberPriceAttribute && coupon) {
1117
+ itemAttributes = itemAttributes.concat([
1118
+ {
1119
+ key: MEMBER_PRICE_ATTRIBUTE_KEY,
1120
+ value: JSON.stringify({ code: coupon.code })
1121
+ }
1122
+ ]);
1123
+ }
1124
+ const couponDiscountAttribute = itemAttributes.find(
1125
+ (attr) => attr.key === CODE_AMOUNT_KEY || attr.key === SCRIPT_CODE_AMOUNT_KEY
1126
+ );
1127
+ if (!couponDiscountAttribute && coupon && Number(coupon?.amount) > 0) {
1128
+ itemAttributes = itemAttributes.concat([
1129
+ {
1130
+ key: CODE_AMOUNT_KEY,
1131
+ value: new Decimal2__default.default(coupon.amount).times(line.quantity || 1).toString()
1132
+ },
1133
+ {
1134
+ key: SCRIPT_CODE_AMOUNT_KEY,
1135
+ value: new Decimal2__default.default(coupon.amount).times(line.quantity || 1).toString()
1136
+ }
1137
+ ]);
1138
+ }
1139
+ return { ...line, attributes: itemAttributes };
1140
+ };
1141
+ var getLinesWithAttributes = ({
1142
+ cart,
1143
+ lineItems
1144
+ }) => {
1145
+ return lineItems.map((line) => {
1146
+ const sameLine = initSameLinesAttributes({ cart, line });
1147
+ const functionLine = initDiscountAttributes({ line: sameLine });
1148
+ return functionLine;
1149
+ });
1150
+ };
984
1151
 
985
1152
  // src/hooks/cart/use-add-to-cart.ts
986
1153
  function useAddToCart({ withTrack = true } = {}, swrOptions) {
987
- const { client, config, locale, cartCookieAdapter, userAdapter } = useShopify();
988
- const { cart } = useCartContext();
1154
+ const { client, config, locale, cartCookieAdapter, userAdapter, performanceAdapter } = useShopify();
1155
+ const { cart, addCustomAttributes } = useCartContext();
989
1156
  const { trigger: applyCartCodes } = useApplyCartCodes();
990
1157
  const { trigger: removeInvalidCodes } = useRemoveCartCodes();
991
1158
  const { trigger: addCartLines2 } = useAddCartLines();
1159
+ const { trigger: createCart4 } = useCreateCart();
992
1160
  const addToCart = react.useCallback(
993
1161
  async (_key, { arg }) => {
994
1162
  const {
@@ -999,12 +1167,15 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
999
1167
  buyerIdentity,
1000
1168
  needCreateCart = false,
1001
1169
  onCodesInvalid,
1002
- replaceExistingCodes
1170
+ replaceExistingCodes,
1171
+ customAttributes
1003
1172
  } = arg;
1004
1173
  if (!lineItems || lineItems.length === 0) {
1005
1174
  return;
1006
1175
  }
1007
- const lines = lineItems.map((item) => ({
1176
+ performanceAdapter?.addToCartStart();
1177
+ const linesWithFunctionAttributes = getLinesWithAttributes({ cart, lineItems });
1178
+ const lines = linesWithFunctionAttributes.map((item) => ({
1008
1179
  merchandiseId: item.variant?.id || "",
1009
1180
  quantity: item.quantity || 1,
1010
1181
  attributes: item.attributes,
@@ -1013,36 +1184,45 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
1013
1184
  if (lines.length === 0) {
1014
1185
  return;
1015
1186
  }
1016
- const cartId = needCreateCart ? void 0 : providedCartId || cart?.id;
1017
- let resultCart = await addCartLines2({
1018
- cartId,
1019
- lines,
1020
- buyerIdentity
1021
- });
1022
- if (!resultCart) {
1023
- return void 0;
1024
- }
1025
- console.log("npm addCartLines resultCart", resultCart);
1026
- if (resultCart.discountCodes && resultCart.discountCodes.length > 0) {
1027
- const unapplicableCodes = resultCart.discountCodes.filter((item) => !item.applicable).map((item) => item.code);
1028
- if (unapplicableCodes.length > 0) {
1029
- if (onCodesInvalid) {
1030
- const handledCart = await onCodesInvalid(resultCart, unapplicableCodes);
1031
- if (handledCart) {
1032
- resultCart = handledCart;
1187
+ let cartId = needCreateCart ? void 0 : providedCartId || cart?.id;
1188
+ let resultCart = null;
1189
+ if (!cartId) {
1190
+ resultCart = await createCart4({
1191
+ lines,
1192
+ buyerIdentity,
1193
+ discountCodes,
1194
+ customAttributes
1195
+ });
1196
+ } else {
1197
+ resultCart = await addCartLines2({
1198
+ cartId,
1199
+ lines
1200
+ });
1201
+ console.log("npm addCartLines resultCart", resultCart);
1202
+ if (resultCart && resultCart.discountCodes && resultCart.discountCodes.length > 0) {
1203
+ const unapplicableCodes = resultCart.discountCodes.filter((item) => !item.applicable).map((item) => item.code);
1204
+ if (unapplicableCodes.length > 0) {
1205
+ if (onCodesInvalid) {
1206
+ const handledCart = await onCodesInvalid(resultCart, unapplicableCodes);
1207
+ if (handledCart) {
1208
+ resultCart = handledCart;
1209
+ }
1210
+ } else {
1211
+ await removeInvalidCodes({
1212
+ discountCodes: unapplicableCodes
1213
+ });
1033
1214
  }
1034
- } else {
1035
- await removeInvalidCodes({
1036
- discountCodes: unapplicableCodes
1037
- });
1038
1215
  }
1039
1216
  }
1040
- }
1041
- if (discountCodes && discountCodes.length > 0) {
1042
- applyCartCodes({
1043
- replaceExistingCodes,
1044
- discountCodes
1045
- });
1217
+ if (resultCart && discountCodes && discountCodes.length > 0) {
1218
+ applyCartCodes({
1219
+ replaceExistingCodes,
1220
+ discountCodes
1221
+ });
1222
+ }
1223
+ if (customAttributes && customAttributes.length > 0) {
1224
+ addCustomAttributes(customAttributes);
1225
+ }
1046
1226
  }
1047
1227
  if (withTrack) {
1048
1228
  trackAddToCartGA({
@@ -1051,9 +1231,24 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
1051
1231
  });
1052
1232
  trackAddToCartFBQ({ lineItems });
1053
1233
  }
1234
+ performanceAdapter?.addToCartEnd();
1054
1235
  return resultCart;
1055
1236
  },
1056
- [client, locale, cartCookieAdapter, userAdapter, cart, withTrack]
1237
+ [
1238
+ client,
1239
+ locale,
1240
+ cartCookieAdapter,
1241
+ userAdapter,
1242
+ cart,
1243
+ withTrack,
1244
+ performanceAdapter,
1245
+ createCart4,
1246
+ addCartLines2,
1247
+ applyCartCodes,
1248
+ removeInvalidCodes,
1249
+ addCustomAttributes,
1250
+ config
1251
+ ]
1057
1252
  );
1058
1253
  return useSWRMutation__default.default("add-to-cart", addToCart, swrOptions);
1059
1254
  }
@@ -1070,9 +1265,10 @@ function useUpdateCartLines(options) {
1070
1265
  if (updatedCart) {
1071
1266
  mutateCart(updatedCart);
1072
1267
  }
1268
+ console.log("use-update-cart-lines updatedCart", metafieldIdentifiers, updatedCart);
1073
1269
  return updatedCart;
1074
1270
  },
1075
- [client, locale, cartCookieAdapter, mutateCart]
1271
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1076
1272
  );
1077
1273
  return useSWRMutation__default.default("update-cart-lines", updateLines, options);
1078
1274
  }
@@ -1111,7 +1307,7 @@ function useRemoveCartLines(options) {
1111
1307
  }
1112
1308
  return updatedCart;
1113
1309
  },
1114
- [client, locale, cartCookieAdapter, mutateCart]
1310
+ [client, locale, cartCookieAdapter, mutateCart, metafieldIdentifiers]
1115
1311
  );
1116
1312
  return useSWRMutation__default.default("remove-cart-lines", removeLines, options);
1117
1313
  }
@@ -1130,7 +1326,7 @@ function useUpdateCartAttributes(mutate, metafieldIdentifiers, options) {
1130
1326
  }
1131
1327
  return updatedCart;
1132
1328
  },
1133
- [client, locale, cartCookieAdapter, mutate]
1329
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
1134
1330
  );
1135
1331
  return useSWRMutation__default.default("update-cart-attributes", updateAttributes, options);
1136
1332
  }
@@ -1152,12 +1348,15 @@ function useBuyNow({ withTrack = true } = {}, swrOptions) {
1152
1348
  if (!lineItems || lineItems.length === 0) {
1153
1349
  return;
1154
1350
  }
1155
- const lines = lineItems.map((item) => ({
1351
+ const linesWithFunctionAttributes = getLinesWithAttributes({
1352
+ lineItems
1353
+ });
1354
+ const lines = linesWithFunctionAttributes.map((item) => ({
1156
1355
  merchandiseId: item.variant?.id || "",
1157
1356
  quantity: item.quantity || 1,
1158
1357
  attributes: item.attributes,
1159
1358
  sellingPlanId: item.sellingPlanId
1160
- })).filter((item) => item.merchandiseId && item.quantity);
1359
+ })).filter((item) => item.merchandiseId);
1161
1360
  if (lines.length === 0) {
1162
1361
  return;
1163
1362
  }
@@ -1212,17 +1411,41 @@ function useCalcGiftsFromLines({
1212
1411
  lines
1213
1412
  });
1214
1413
  const allGiftLines = react.useMemo(() => {
1215
- const functionGiftLines = functionGift.qualifyingGift?.itemsToAdd || [];
1216
- const scriptGiftLines = scriptGift.freeGiftLevel ? scriptGift.freeGiftLevel.giveawayProducts.map((product) => {
1217
- const giftProduct = scriptGift.giftProductsResult?.find(
1218
- (p) => p.handle === product.handle
1414
+ const functionGiftLines = (functionGift.qualifyingGift?.itemsToAdd || []).map((item) => {
1415
+ const product = functionGift.giftProductsResult?.find(
1416
+ (product2) => product2.handle === item.variant.handle
1219
1417
  );
1220
- const variant = giftProduct?.variants?.[0];
1418
+ const variants = product?.variants;
1419
+ const variant = Array.isArray(variants) ? variants.find((v) => v.sku === item.variant.sku) : void 0;
1420
+ if (!variant) {
1421
+ console.warn(
1422
+ `Function gift: Variant not found for handle=${item.variant.handle}, sku=${item.variant.sku}`
1423
+ );
1424
+ return null;
1425
+ }
1221
1426
  return {
1222
1427
  variant: {
1223
- id: variant?.id || "",
1224
- handle: product.handle,
1225
- sku: product.sku
1428
+ ...variant,
1429
+ product
1430
+ },
1431
+ quantity: item.quantity ?? 1,
1432
+ attributes: item.attributes
1433
+ };
1434
+ }).filter((item) => item !== null);
1435
+ const scriptGiftLines = scriptGift.freeGiftLevel ? scriptGift.freeGiftLevel.giveawayProducts.map((item) => {
1436
+ const product = scriptGift.giftProductsResult?.find(
1437
+ (product2) => product2.handle === item.handle
1438
+ );
1439
+ const variants = product?.variants;
1440
+ const variant = Array.isArray(variants) ? variants.find((v) => v.sku === item.sku) : void 0;
1441
+ if (!variant) {
1442
+ console.warn(`Script gift: Variant not found for handle=${item.handle}, sku=${item.sku}`);
1443
+ return null;
1444
+ }
1445
+ return {
1446
+ variant: {
1447
+ ...variant,
1448
+ product
1226
1449
  },
1227
1450
  quantity: 1,
1228
1451
  attributes: [
@@ -1232,10 +1455,11 @@ function useCalcGiftsFromLines({
1232
1455
  }
1233
1456
  ]
1234
1457
  };
1235
- }).filter((item) => item.variant.id) : [];
1458
+ }).filter((item) => item !== null) : [];
1236
1459
  return [...functionGiftLines, ...scriptGiftLines];
1237
1460
  }, [
1238
1461
  functionGift.qualifyingGift,
1462
+ functionGift.giftProductsResult,
1239
1463
  scriptGift.freeGiftLevel,
1240
1464
  scriptGift.giftProductsResult,
1241
1465
  scriptGiveawayKey
@@ -1270,7 +1494,7 @@ var useCalcOrderDiscount = (cart, orderDiscountConfig, customer) => {
1270
1494
  const isCustomerLoading = react.useMemo(() => !customer ? true : false, [customer]);
1271
1495
  const dealsType = "";
1272
1496
  const { activeCampaign, subtotal } = react.useMemo(() => {
1273
- for (const campaign of orderDiscountConfig) {
1497
+ for (const campaign of orderDiscountConfig || []) {
1274
1498
  const { rule_conditions = [], result_detail } = campaign;
1275
1499
  const { main_product, order_discount_conf } = result_detail || {};
1276
1500
  const isPreCheckPassed = preCheck(rule_conditions, tags, []);
@@ -1300,9 +1524,12 @@ var useCalcOrderDiscount = (cart, orderDiscountConfig, customer) => {
1300
1524
  discountAmount: 0
1301
1525
  };
1302
1526
  }
1303
- const tieredDiscounts = activeCampaign.result_detail.order_discount_conf.tiered_discounts;
1304
- const qualifyingTier = [...tieredDiscounts].reverse().find((tier) => subtotal >= Number(tier.amount));
1305
- const nextGoal = tieredDiscounts.find((tier) => subtotal < Number(tier.amount));
1527
+ const currentCurrency = cart?.currency?.code || "";
1528
+ console.log("currentCurrency", cart, currentCurrency);
1529
+ const orderDiscountConf = activeCampaign.result_detail.order_discount_conf;
1530
+ const tieredDiscounts = orderDiscountConf.tiered_discounts_markets?.[currentCurrency] || orderDiscountConf.tiered_discounts;
1531
+ const qualifyingTier = [...tieredDiscounts].sort((a, b) => Number(b.amount) - Number(a.amount)).find((tier) => subtotal >= Number(tier.amount));
1532
+ const nextGoal = [...tieredDiscounts].sort((a, b) => Number(a.amount) - Number(b.amount)).find((tier) => subtotal < Number(tier.amount));
1306
1533
  if (!qualifyingTier) {
1307
1534
  return {
1308
1535
  qualifyingDiscount: null,
@@ -1370,12 +1597,10 @@ function useHasPlusMemberInCart({
1370
1597
  };
1371
1598
  }, [cart?.lineItems, plus_monthly_product, plus_annual_product]);
1372
1599
  }
1373
-
1374
- // src/hooks/cart/feature/use-cart-attributes.ts
1375
1600
  var getReferralAttributes = () => {
1376
- const inviteCode = Cookies5__default.default.get("invite_code");
1377
- const playModeId = Cookies5__default.default.get("playModeId");
1378
- const popup = Cookies5__default.default.get("_popup");
1601
+ const inviteCode = shopifySdk.getLocalStorage("inviteCode") || Cookies5__default.default.get("inviteCode");
1602
+ const playModeId = shopifySdk.getLocalStorage("playModeId") || Cookies5__default.default.get("playModeId");
1603
+ const popup = shopifySdk.getLocalStorage("_popup") || Cookies5__default.default.get("_popup");
1379
1604
  if (inviteCode && playModeId) {
1380
1605
  return popup ? [
1381
1606
  { key: "_invite_code", value: inviteCode ? inviteCode : "" },
@@ -1399,8 +1624,6 @@ var useCartAttributes = ({
1399
1624
  memberSetting,
1400
1625
  cart
1401
1626
  });
1402
- console.log("memberSetting", memberSetting);
1403
- console.log("hasPlusMember", hasPlusMember);
1404
1627
  react.useEffect(() => {
1405
1628
  setCurrentUrl(window.location.href);
1406
1629
  }, []);
@@ -1426,7 +1649,7 @@ var useCartAttributes = ({
1426
1649
  return "new_user_login";
1427
1650
  }, [customer]);
1428
1651
  const memberAttributes = react.useMemo(() => {
1429
- return [
1652
+ const attributes = [
1430
1653
  {
1431
1654
  key: "_token",
1432
1655
  value: profile?.token
@@ -1447,17 +1670,28 @@ var useCartAttributes = ({
1447
1670
  value: profile?.token ? "true" : "false"
1448
1671
  }
1449
1672
  ];
1673
+ if (profile?.token) {
1674
+ attributes.push({
1675
+ key: "_login_user",
1676
+ value: "1"
1677
+ });
1678
+ }
1679
+ return attributes;
1450
1680
  }, [profile?.memberType, profile?.token, userType, hasPlusMember]);
1451
1681
  const functionAttributes = react.useMemo(() => {
1452
- return [
1453
- cart?.discountCodes && {
1682
+ const hasFunctionEnvAttribute = cart?.lineItems.some(
1683
+ (item) => item.customAttributes?.some((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY)
1684
+ );
1685
+ const discountCodes = cart?.discountCodes.map((item) => item.code).filter((code) => code) || [];
1686
+ return hasFunctionEnvAttribute ? [
1687
+ {
1454
1688
  key: "_discounts_function_env",
1455
1689
  value: JSON.stringify({
1456
- discount_code: cart?.discountCodes.map((item) => item.code),
1690
+ discount_code: discountCodes,
1457
1691
  user_tags: customer?.tags || []
1458
1692
  })
1459
1693
  }
1460
- ];
1694
+ ] : [];
1461
1695
  }, [cart]);
1462
1696
  const presellAttributes = react.useMemo(() => {
1463
1697
  return [
@@ -1489,18 +1723,50 @@ var useCartAttributes = ({
1489
1723
  }
1490
1724
  ];
1491
1725
  }, [currentUrl]);
1726
+ const commonAttributes = react.useMemo(
1727
+ () => [
1728
+ ...memberAttributes,
1729
+ ...functionAttributes,
1730
+ ...presellAttributes,
1731
+ ...weightAttributes,
1732
+ ...trackingAttributes,
1733
+ ...getReferralAttributes()
1734
+ ].filter((item) => item?.value),
1735
+ [memberAttributes, functionAttributes, presellAttributes, weightAttributes, trackingAttributes]
1736
+ );
1737
+ const extraAttributesInCart = react.useMemo(() => {
1738
+ const commonAttributeKeys = [
1739
+ // member attributes
1740
+ "_token",
1741
+ "_member_type",
1742
+ "_user_type",
1743
+ "_is_login",
1744
+ "_login_user",
1745
+ // function attributes
1746
+ "_discounts_function_env",
1747
+ // presell attributes
1748
+ "_presale",
1749
+ // weight attributes
1750
+ "_weight",
1751
+ "_app_source_name",
1752
+ // tracking attributes
1753
+ "utm_params",
1754
+ // referral attributes
1755
+ "_invite_code",
1756
+ "_play_mode_id",
1757
+ "_popup"
1758
+ ];
1759
+ return cart?.customAttributes?.filter(
1760
+ (item) => !commonAttributeKeys.includes(item.key)
1761
+ ) || [];
1762
+ }, [cart]);
1492
1763
  return react.useMemo(
1493
1764
  () => ({
1494
- attributes: [
1495
- ...memberAttributes,
1496
- ...functionAttributes,
1497
- ...presellAttributes,
1498
- ...weightAttributes,
1499
- ...trackingAttributes,
1500
- ...getReferralAttributes()
1501
- ].filter((item) => item?.value)
1765
+ attributes: [...commonAttributes, ...extraAttributesInCart].filter(
1766
+ (item) => item?.value
1767
+ )
1502
1768
  }),
1503
- [memberAttributes, functionAttributes, presellAttributes, weightAttributes, trackingAttributes]
1769
+ [commonAttributes, extraAttributesInCart]
1504
1770
  );
1505
1771
  };
1506
1772
  var DEFAULT_MIN = 1;
@@ -1563,7 +1829,7 @@ var useUpdateLineCodeAmountAttributes = ({
1563
1829
  );
1564
1830
  const functionEnvValue = getDiscountEnvAttributeValue(line.customAttributes);
1565
1831
  const hasSameFunctionEnvAttribute = Number(functionEnvValue.discounted_amount) === Number(line.totalAmount);
1566
- if (!hasSameFunctionEnvAttribute && hasFunctionEnvAttribute) {
1832
+ if (!hasSameFunctionEnvAttribute && hasFunctionEnvAttribute && !functionEnvValue.is_gift) {
1567
1833
  attrNeedUpdate.push({
1568
1834
  key: CUSTOMER_ATTRIBUTE_KEY,
1569
1835
  value: JSON.stringify({
@@ -1602,29 +1868,22 @@ var useUpdateLineCodeAmountAttributes = ({
1602
1868
  }).filter(
1603
1869
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
1604
1870
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
1871
+ let lineId = line.id;
1872
+ let attributes = line.customAttributes || [];
1873
+ if (attrNeedDelete.length) {
1874
+ attributes = attributes.filter(
1875
+ (attr) => !attrNeedDelete.includes(attr.key)
1876
+ );
1877
+ }
1605
1878
  if (attrNeedUpdate.length) {
1606
- return {
1607
- id: line.id,
1608
- attributes: [
1609
- ...line.customAttributes?.filter(
1610
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1611
- ) || [],
1612
- ...attrNeedUpdate
1613
- ]
1614
- };
1615
- } else if (attrNeedDelete.length) {
1616
- return {
1617
- id: line.id,
1618
- attributes: line.customAttributes?.filter(
1619
- (attr) => !attrNeedDelete.includes(attr.key)
1620
- ) || []
1621
- };
1622
- } else {
1623
- return {
1624
- id: line.id,
1625
- attributes: line.customAttributes || []
1626
- };
1879
+ attributes = attributes.filter(
1880
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1881
+ ).concat(attrNeedUpdate);
1627
1882
  }
1883
+ return {
1884
+ id: lineId,
1885
+ attributes
1886
+ };
1628
1887
  }),
1629
1888
  [cart?.lineItems, mainProductDiscountCodes]
1630
1889
  );
@@ -1717,8 +1976,9 @@ function useProductsByHandles(options = {}) {
1717
1976
  metafieldIdentifiers
1718
1977
  });
1719
1978
  },
1720
- swrOptions || {
1721
- revalidateOnFocus: false
1979
+ {
1980
+ revalidateOnFocus: false,
1981
+ ...swrOptions
1722
1982
  }
1723
1983
  );
1724
1984
  }
@@ -2347,7 +2607,10 @@ var createInitialValue = () => ({
2347
2607
  freeShippingMethods: [],
2348
2608
  paymentShippingMethods: [],
2349
2609
  nddOverweight: false,
2350
- tddOverweight: false
2610
+ tddOverweight: false,
2611
+ nddCoupon: void 0,
2612
+ tddCoupon: void 0,
2613
+ isLoadingCoupon: false
2351
2614
  },
2352
2615
  selectedPlusMemberProduct: null,
2353
2616
  plusMemberProducts: [],
@@ -2392,15 +2655,29 @@ function usePlusAnnualProductVariant() {
2392
2655
  }, [plusMemberProducts, plusAnnual]);
2393
2656
  return plusAnnualProductVariant;
2394
2657
  }
2395
- function useShippingMethods(options) {
2396
- const {
2397
- variant,
2398
- plusMemberMetafields,
2399
- selectedPlusMemberMode,
2400
- isPlus = false,
2658
+ var useAvailableDeliveryCoupon = ({
2659
+ profile
2660
+ }) => {
2661
+ const { data: availableDeliveryCoupon, isLoading } = useSWR__default.default(
2662
+ profile?.email ? ["/api/multipass/subsrv/v1/prime/delivery_coupons/current/available", profile?.email] : void 0,
2663
+ async ([apiPath]) => {
2664
+ return fetch(apiPath).then((res) => res.json());
2665
+ }
2666
+ );
2667
+ console.log("availableDeliveryCoupon", availableDeliveryCoupon);
2668
+ const { ndd_coupon: nddCoupon, tdd_coupon: tddCoupon } = availableDeliveryCoupon?.data?.data || {};
2669
+ return {
2401
2670
  nddCoupon,
2402
- tddCoupon
2403
- } = options;
2671
+ tddCoupon,
2672
+ isLoading
2673
+ };
2674
+ };
2675
+
2676
+ // src/hooks/member/plus/use-shipping-methods.ts
2677
+ function useShippingMethods(options) {
2678
+ const { variant, plusMemberMetafields, selectedPlusMemberMode, isPlus = false, profile } = options;
2679
+ const { nddCoupon, tddCoupon, isLoading } = useAvailableDeliveryCoupon({ profile });
2680
+ console.log("nddCoupon", nddCoupon);
2404
2681
  const { plus_shipping, shippingMethod } = plusMemberMetafields || {};
2405
2682
  const nddOverweight = react.useMemo(() => {
2406
2683
  return (variant?.weight || 0) > (shippingMethod?.overWeight_ndd || Infinity);
@@ -2410,12 +2687,10 @@ function useShippingMethods(options) {
2410
2687
  }, [shippingMethod?.overWeight_tdd, variant?.weight]);
2411
2688
  const paymentShippingMethods = react.useMemo(() => {
2412
2689
  const weight = variant?.weight || 0;
2413
- const methods = plus_shipping?.shipping_methods?.filter(
2414
- ({ weight_low, weight_high, __mode, __plus }) => {
2415
- const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2416
- return __mode !== "free" /* FREE */ && !__plus && fitWeight;
2417
- }
2418
- ) || [];
2690
+ const methods = plus_shipping?.shipping_methods?.filter(({ weight_low, weight_high, __mode, __plus }) => {
2691
+ const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2692
+ return __mode !== "free" /* FREE */ && !__plus && fitWeight;
2693
+ }) || [];
2419
2694
  return methods.map((method) => {
2420
2695
  let disabled = false;
2421
2696
  const selectedFreeMember = selectedPlusMemberMode === "free";
@@ -2442,40 +2717,34 @@ function useShippingMethods(options) {
2442
2717
  ]);
2443
2718
  const nddPrice = react.useMemo(() => {
2444
2719
  const weight = variant?.weight || 0;
2445
- const nddMethod = paymentShippingMethods.find(
2446
- ({ __mode, weight_high, weight_low }) => {
2447
- const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2448
- return __mode === "ndd" && fitWeight;
2449
- }
2450
- );
2720
+ const nddMethod = paymentShippingMethods.find(({ __mode, weight_high, weight_low }) => {
2721
+ const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2722
+ return __mode === "ndd" && fitWeight;
2723
+ });
2451
2724
  return nddMethod?.price || 0;
2452
2725
  }, [variant?.weight, paymentShippingMethods]);
2453
2726
  const tddPrice = react.useMemo(() => {
2454
2727
  const weight = variant?.weight || 0;
2455
- const tddMethod = paymentShippingMethods.find(
2456
- ({ __mode, weight_high, weight_low }) => {
2457
- const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2458
- return __mode === "tdd" && fitWeight;
2459
- }
2460
- );
2728
+ const tddMethod = paymentShippingMethods.find(({ __mode, weight_high, weight_low }) => {
2729
+ const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2730
+ return __mode === "tdd" && fitWeight;
2731
+ });
2461
2732
  return tddMethod?.price || 0;
2462
2733
  }, [variant?.weight, paymentShippingMethods]);
2463
2734
  const freeShippingMethods = react.useMemo(() => {
2464
2735
  const weight = variant?.weight || 0;
2465
- let methods = plus_shipping?.shipping_methods?.filter(
2466
- ({ __mode, __plus, weight_low, weight_high }) => {
2467
- if (__mode === "free" /* FREE */) {
2468
- return true;
2469
- }
2470
- if (isPlus) {
2471
- const hasCoupon = isPlus && __mode === "ndd" /* NDD */ && nddCoupon || isPlus && __mode === "tdd" /* TDD */ && (tddCoupon || nddCoupon);
2472
- const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2473
- return hasCoupon && fitWeight && !__plus;
2474
- } else {
2475
- return __plus;
2476
- }
2736
+ let methods = plus_shipping?.shipping_methods?.filter(({ __mode, __plus, weight_low, weight_high }) => {
2737
+ if (__mode === "free" /* FREE */) {
2738
+ return true;
2477
2739
  }
2478
- ) || [];
2740
+ if (isPlus) {
2741
+ const hasCoupon = isPlus && __mode === "ndd" /* NDD */ && nddCoupon || isPlus && __mode === "tdd" /* TDD */ && (tddCoupon || nddCoupon);
2742
+ const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
2743
+ return hasCoupon && fitWeight && !__plus;
2744
+ } else {
2745
+ return __plus;
2746
+ }
2747
+ }) || [];
2479
2748
  if (isPlus) {
2480
2749
  methods = methods.sort((a, b) => {
2481
2750
  if (b.__mode === "free" /* FREE */) return -1;
@@ -2529,7 +2798,10 @@ function useShippingMethods(options) {
2529
2798
  freeShippingMethods,
2530
2799
  paymentShippingMethods,
2531
2800
  nddOverweight,
2532
- tddOverweight
2801
+ tddOverweight,
2802
+ nddCoupon,
2803
+ tddCoupon,
2804
+ isLoadingCoupon: isLoading
2533
2805
  };
2534
2806
  }
2535
2807
  function useShippingMethodAvailableCheck() {
@@ -2634,6 +2906,73 @@ var usePlusMemberDeliveryCodes = ({
2634
2906
  [deliveryData]
2635
2907
  );
2636
2908
  };
2909
+ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
2910
+ const { client, locale, cartCookieAdapter } = useShopify();
2911
+ const updateDeliveryOptions = react.useCallback(
2912
+ async (_key, { arg }) => {
2913
+ const updatedCart = await shopifySdk.updateCartDeliveryOptions(client, {
2914
+ ...arg,
2915
+ metafieldIdentifiers,
2916
+ cookieAdapter: cartCookieAdapter
2917
+ });
2918
+ console.log("useUpdateCartDeliveryOptions updatedCart", updatedCart);
2919
+ if (updatedCart) {
2920
+ mutate(updatedCart);
2921
+ }
2922
+ return updatedCart;
2923
+ },
2924
+ [client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
2925
+ );
2926
+ return useSWRMutation__default.default("update-cart-delivery-options", updateDeliveryOptions, options);
2927
+ }
2928
+
2929
+ // src/hooks/member/plus/use-update-plus-member-delivery-options.ts
2930
+ var useUpdatePlusMemberDeliveryOptions = ({
2931
+ options
2932
+ } = {}) => {
2933
+ const { cart: cartContextData, mutateCart, metafieldIdentifiers } = useCartContext();
2934
+ const { trigger: updateCartDeliveryOptions2 } = useUpdateCartDeliveryOptions(
2935
+ mutateCart,
2936
+ metafieldIdentifiers
2937
+ );
2938
+ const handler = react.useCallback(
2939
+ async (_, { arg }) => {
2940
+ const currentCart = arg?.cart || cartContextData;
2941
+ const { deliveryData } = arg;
2942
+ const firstDeliveryGroup = currentCart?.deliveryGroups?.[0];
2943
+ const deliveryGroupId = firstDeliveryGroup?.id;
2944
+ const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option?.code;
2945
+ if (!deliveryGroupId || !selectedOptionCode || selectedOptionCode === firstDeliveryGroup?.selectedDeliveryOption?.code) {
2946
+ return null;
2947
+ }
2948
+ const deliveryGroup = currentCart?.deliveryGroups?.find(
2949
+ (group) => group?.id === deliveryGroupId
2950
+ );
2951
+ const matchedOption = deliveryGroup?.deliveryOptions?.find(
2952
+ (option) => option?.code === selectedOptionCode
2953
+ );
2954
+ if (!matchedOption?.handle) {
2955
+ return null;
2956
+ }
2957
+ const deliveryOptions = [
2958
+ {
2959
+ deliveryGroupId,
2960
+ deliveryOptionHandle: matchedOption.handle
2961
+ }
2962
+ ];
2963
+ const updatedCart = await updateCartDeliveryOptions2({
2964
+ selectedDeliveryOptions: deliveryOptions,
2965
+ cartId: currentCart?.id
2966
+ });
2967
+ if (updatedCart && mutateCart) {
2968
+ mutateCart(updatedCart);
2969
+ }
2970
+ return updatedCart;
2971
+ },
2972
+ [cartContextData, updateCartDeliveryOptions2, mutateCart]
2973
+ );
2974
+ return useSWRMutation__default.default("update-cart-delivery-options", handler, options);
2975
+ };
2637
2976
  var usePlusMemberItemCustomAttributes = ({
2638
2977
  deliveryData
2639
2978
  }) => {
@@ -2653,48 +2992,18 @@ var usePlusMemberCheckoutCustomAttributes = ({
2653
2992
  deliveryData,
2654
2993
  product,
2655
2994
  variant,
2656
- customer,
2657
2995
  isShowShippingBenefits
2658
2996
  }) => {
2659
2997
  const { deliveryCustomData } = deliveryData || {};
2660
2998
  const { profile } = usePlusMemberContext();
2661
- const userType = react.useMemo(() => {
2662
- const customerInfo = customer;
2663
- if (!customerInfo) {
2664
- return "new_user_unlogin";
2665
- }
2666
- if (customer) {
2667
- const { orders = {} } = customer;
2668
- const edgesLength = orders?.edges?.length;
2669
- if (edgesLength === 1) {
2670
- return "old_user_orders_once";
2671
- } else if (edgesLength && edgesLength > 1) {
2672
- return "old_user_orders_twice";
2673
- }
2674
- }
2675
- return "new_user_login";
2676
- }, [customer]);
2677
2999
  return react.useMemo(() => {
2678
3000
  const checkoutCustomAttributes = [
2679
- {
2680
- key: "_token",
2681
- value: profile?.token || ""
2682
- },
3001
+ // _last_url: 付费会员结算完成之后 checkout 有一个继续购买的按钮, 用于跳转到继续购买的页面
2683
3002
  {
2684
3003
  key: "_last_url",
2685
3004
  value: typeof window !== "undefined" ? window.location.origin + window.location.pathname : ""
2686
- },
2687
- {
2688
- key: "_user_type",
2689
- value: userType
2690
3005
  }
2691
3006
  ];
2692
- if (profile) {
2693
- checkoutCustomAttributes.push({
2694
- key: "_login_user",
2695
- value: "1"
2696
- });
2697
- }
2698
3007
  if (deliveryCustomData) {
2699
3008
  checkoutCustomAttributes.push({
2700
3009
  key: "_checkout_delivery_custom",
@@ -2704,12 +3013,6 @@ var usePlusMemberCheckoutCustomAttributes = ({
2704
3013
  })
2705
3014
  });
2706
3015
  }
2707
- if (variant?.metafields?.presell) {
2708
- checkoutCustomAttributes.push({
2709
- key: "_presale",
2710
- value: "true"
2711
- });
2712
- }
2713
3016
  if (isShowShippingBenefits && !isShowShippingBenefits({ variant, product, setting: {} })) {
2714
3017
  checkoutCustomAttributes.push({
2715
3018
  key: "_hide_shipping",
@@ -2717,18 +3020,17 @@ var usePlusMemberCheckoutCustomAttributes = ({
2717
3020
  });
2718
3021
  }
2719
3022
  return checkoutCustomAttributes;
2720
- }, [deliveryCustomData, product, profile, userType, variant, isShowShippingBenefits]);
3023
+ }, [deliveryCustomData, product, profile, variant, isShowShippingBenefits]);
2721
3024
  };
2722
3025
  function useAutoRemovePlusMemberInCart({
2723
- metafields,
2724
- isMonthlyPlus,
2725
- isAnnualPlus
3026
+ cart,
3027
+ profile,
3028
+ memberSetting
2726
3029
  }) {
2727
- const { plus_monthly_product, plus_annual_product } = metafields || {};
2728
- const { cart } = useCartContext();
3030
+ const { plus_monthly_product, plus_annual_product } = memberSetting || {};
2729
3031
  const { trigger: removeCartLines2 } = useRemoveCartLines();
2730
3032
  react.useEffect(() => {
2731
- if (!cart) return;
3033
+ if (!cart || !plus_monthly_product || !plus_annual_product) return;
2732
3034
  const removePlusProduct = async (productType) => {
2733
3035
  if (!productType) return;
2734
3036
  const product = cart.lineItems?.find(
@@ -2740,33 +3042,25 @@ function useAutoRemovePlusMemberInCart({
2740
3042
  });
2741
3043
  }
2742
3044
  };
2743
- if (isMonthlyPlus) {
3045
+ if (profile?.isMonthlyPlus) {
2744
3046
  removePlusProduct(plus_monthly_product);
2745
3047
  }
2746
- if (isAnnualPlus) {
3048
+ if (profile?.isAnnualPlus) {
2747
3049
  removePlusProduct(plus_annual_product);
2748
3050
  }
2749
- }, [
2750
- cart,
2751
- plus_annual_product,
2752
- plus_monthly_product,
2753
- isAnnualPlus,
2754
- isMonthlyPlus,
2755
- removeCartLines2
2756
- ]);
3051
+ }, [cart, plus_annual_product, plus_monthly_product, profile, removeCartLines2]);
2757
3052
  }
2758
- function useAddPlusMemberProductsToCart({
3053
+ function usePlusMemberNeedAddToCart({
2759
3054
  cart,
2760
- memberSetting,
2761
- selectedPlusMemberMode,
2762
- selectedPlusMemberProduct
3055
+ profile
2763
3056
  }) {
3057
+ const { selectedPlusMemberMode, selectedPlusMemberProduct, plusMemberMetafields } = usePlusMemberContext();
2764
3058
  const { hasMonthlyPlus, hasAnnualPlus } = useHasPlusMemberInCart({
2765
- cart,
2766
- memberSetting
3059
+ memberSetting: plusMemberMetafields,
3060
+ cart
2767
3061
  });
2768
3062
  const plusMemberProduct = react.useMemo(() => {
2769
- if (selectedPlusMemberMode === "free" /* FREE */) {
3063
+ if (!selectedPlusMemberProduct || selectedPlusMemberMode === "free" /* FREE */) {
2770
3064
  return void 0;
2771
3065
  }
2772
3066
  if (selectedPlusMemberMode === "monthly" /* MONTHLY */ && hasMonthlyPlus) {
@@ -2775,7 +3069,10 @@ function useAddPlusMemberProductsToCart({
2775
3069
  if (selectedPlusMemberMode === "annual" /* ANNUAL */ && hasAnnualPlus) {
2776
3070
  return void 0;
2777
3071
  }
2778
- if (!selectedPlusMemberProduct) {
3072
+ if (profile?.isMonthlyPlus && selectedPlusMemberMode === "monthly" /* MONTHLY */) {
3073
+ return void 0;
3074
+ }
3075
+ if (profile?.isAnnualPlus && selectedPlusMemberMode === "annual" /* ANNUAL */) {
2779
3076
  return void 0;
2780
3077
  }
2781
3078
  return selectedPlusMemberProduct;
@@ -2794,9 +3091,9 @@ var PlusMemberProvider = ({
2794
3091
  memberSetting,
2795
3092
  initialSelectedPlusMemberMode = "free",
2796
3093
  profile,
2797
- locale,
2798
3094
  children
2799
3095
  }) => {
3096
+ const { locale } = useShopify();
2800
3097
  const [zipCode, setZipCode] = react.useState("");
2801
3098
  const [showTip, setShowTip] = react.useState(false);
2802
3099
  const [selectedPlusMemberMode, setSelectedPlusMemberMode] = react.useState(
@@ -2812,7 +3109,11 @@ var PlusMemberProvider = ({
2812
3109
  const shippingMethodsContext = useShippingMethods({
2813
3110
  variant,
2814
3111
  plusMemberMetafields: memberSetting,
2815
- selectedPlusMemberMode});
3112
+ selectedPlusMemberMode,
3113
+ profile,
3114
+ isPlus: profile?.isPlus || false
3115
+ });
3116
+ console.log("shippingMethodsContext", shippingMethodsContext);
2816
3117
  const plusMemberHandles = react.useMemo(() => {
2817
3118
  return [
2818
3119
  memberSetting?.plus_monthly_product?.handle,
@@ -3094,8 +3395,13 @@ function CartProvider({
3094
3395
  const { attributes } = useCartAttributes({ profile, customer, cart, memberSetting });
3095
3396
  ahooks.useRequest(
3096
3397
  () => {
3097
- const newAttributes = [...attributes, ...customAttributes];
3098
- const needUpdate = cart && !checkAttributesUpdateNeeded(
3398
+ const newAttributes = [...attributes];
3399
+ customAttributes.forEach((item) => {
3400
+ if (item.value && !newAttributes.some((attr) => attr.key === item.key)) {
3401
+ newAttributes.push(item);
3402
+ }
3403
+ });
3404
+ const needUpdate = cart && checkAttributesUpdateNeeded(
3099
3405
  cart.customAttributes,
3100
3406
  newAttributes,
3101
3407
  customAttributesNeedDelete
@@ -3118,7 +3424,8 @@ function CartProvider({
3118
3424
  cart,
3119
3425
  mutateCart,
3120
3426
  isCartLoading: isCartLoading || isCodeChanging,
3121
- setLoadingState
3427
+ setLoadingState,
3428
+ metafieldIdentifiers
3122
3429
  });
3123
3430
  const removeCustomAttributes = react.useCallback(
3124
3431
  (attributes2) => {
@@ -3199,8 +3506,14 @@ function CartProvider({
3199
3506
  );
3200
3507
  return result;
3201
3508
  }, [cart?.lineItems, scriptAutoFreeGift, functionAutoFreeGift]);
3509
+ const totalQuantity = react.useMemo(() => {
3510
+ const cartLinesCount = cart?.lineItems.reduce((acc, item) => acc + item.quantity, 0) || 0;
3511
+ const giftLinesCount = giftNeedAddToCartLines?.reduce((acc, item) => acc + (item.quantity || 1), 0) || 0;
3512
+ return cartLinesCount + giftLinesCount;
3513
+ }, [cart?.lineItems, giftNeedAddToCartLines]);
3202
3514
  const value = react.useMemo(
3203
3515
  () => ({
3516
+ totalQuantity,
3204
3517
  cart,
3205
3518
  isCartLoading,
3206
3519
  triggerFetch: fetchCart,
@@ -3228,6 +3541,7 @@ function CartProvider({
3228
3541
  }),
3229
3542
  [
3230
3543
  cart,
3544
+ totalQuantity,
3231
3545
  isCartLoading,
3232
3546
  fetchCart,
3233
3547
  mutateCart,
@@ -3252,38 +3566,15 @@ function CartProvider({
3252
3566
  );
3253
3567
  return /* @__PURE__ */ jsxRuntime.jsx(CartContext.Provider, { value, children });
3254
3568
  }
3255
- function useCartContext() {
3569
+ function useCartContext(options) {
3256
3570
  const context = react.useContext(CartContext);
3257
- if (!context) {
3571
+ if (!context && !options?.optional) {
3258
3572
  throw new Error("useCartContext must be used within a CartProvider");
3259
3573
  }
3260
3574
  return context;
3261
3575
  }
3262
3576
 
3263
- Object.defineProperty(exports, "ShopifyConfig", {
3264
- enumerable: true,
3265
- get: function () { return shopifySdk.ShopifyConfig; }
3266
- });
3267
- Object.defineProperty(exports, "clearLocalStorage", {
3268
- enumerable: true,
3269
- get: function () { return shopifySdk.clearLocalStorage; }
3270
- });
3271
- Object.defineProperty(exports, "createShopifyClient", {
3272
- enumerable: true,
3273
- get: function () { return shopifySdk.createShopifyClient; }
3274
- });
3275
- Object.defineProperty(exports, "getLocalStorage", {
3276
- enumerable: true,
3277
- get: function () { return shopifySdk.getLocalStorage; }
3278
- });
3279
- Object.defineProperty(exports, "removeLocalStorage", {
3280
- enumerable: true,
3281
- get: function () { return shopifySdk.removeLocalStorage; }
3282
- });
3283
- Object.defineProperty(exports, "setLocalStorage", {
3284
- enumerable: true,
3285
- get: function () { return shopifySdk.setLocalStorage; }
3286
- });
3577
+ exports.BrowserPerformanceAdapter = BrowserPerformanceAdapter;
3287
3578
  exports.BuyRuleType = BuyRuleType;
3288
3579
  exports.CODE_AMOUNT_KEY = CODE_AMOUNT_KEY;
3289
3580
  exports.CUSTOMER_ATTRIBUTE_KEY = CUSTOMER_ATTRIBUTE_KEY;
@@ -3291,6 +3582,7 @@ exports.CUSTOMER_SCRIPT_GIFT_KEY = CUSTOMER_SCRIPT_GIFT_KEY;
3291
3582
  exports.CartProvider = CartProvider;
3292
3583
  exports.DeliveryPlusType = DeliveryPlusType;
3293
3584
  exports.MAIN_PRODUCT_CODE = MAIN_PRODUCT_CODE;
3585
+ exports.MEMBER_PRICE_ATTRIBUTE_KEY = MEMBER_PRICE_ATTRIBUTE_KEY;
3294
3586
  exports.OrderBasePriceType = OrderBasePriceType;
3295
3587
  exports.OrderDiscountType = OrderDiscountType;
3296
3588
  exports.PLUS_MEMBER_TYPE = PLUS_MEMBER_TYPE;
@@ -3305,10 +3597,8 @@ exports.ShippingMethodMode = ShippingMethodMode;
3305
3597
  exports.ShopifyContext = ShopifyContext;
3306
3598
  exports.ShopifyProvider = ShopifyProvider;
3307
3599
  exports.SpendMoneyType = SpendMoneyType;
3308
- exports.atobID = atobID;
3309
3600
  exports.browserCartCookieAdapter = browserCartCookieAdapter;
3310
3601
  exports.browserCookieAdapter = browserCookieAdapter;
3311
- exports.btoaID = btoaID;
3312
3602
  exports.checkAttributesUpdateNeeded = checkAttributesUpdateNeeded;
3313
3603
  exports.clearGeoLocationCache = clearGeoLocationCache;
3314
3604
  exports.createMockCartFromLines = createMockCartFromLines;
@@ -3331,7 +3621,6 @@ exports.trackBeginCheckoutGA = trackBeginCheckoutGA;
3331
3621
  exports.trackBuyNowFBQ = trackBuyNowFBQ;
3332
3622
  exports.trackBuyNowGA = trackBuyNowGA;
3333
3623
  exports.useAddCartLines = useAddCartLines;
3334
- exports.useAddPlusMemberProductsToCart = useAddPlusMemberProductsToCart;
3335
3624
  exports.useAddToCart = useAddToCart;
3336
3625
  exports.useAllBlogs = useAllBlogs;
3337
3626
  exports.useAllCollections = useAllCollections;
@@ -3341,6 +3630,7 @@ exports.useArticle = useArticle;
3341
3630
  exports.useArticles = useArticles;
3342
3631
  exports.useArticlesInBlog = useArticlesInBlog;
3343
3632
  exports.useAutoRemovePlusMemberInCart = useAutoRemovePlusMemberInCart;
3633
+ exports.useAvailableDeliveryCoupon = useAvailableDeliveryCoupon;
3344
3634
  exports.useBlog = useBlog;
3345
3635
  exports.useBuyNow = useBuyNow;
3346
3636
  exports.useCalcAutoFreeGift = useCalcAutoFreeGift;
@@ -3361,6 +3651,7 @@ exports.usePlusMemberCheckoutCustomAttributes = usePlusMemberCheckoutCustomAttri
3361
3651
  exports.usePlusMemberContext = usePlusMemberContext;
3362
3652
  exports.usePlusMemberDeliveryCodes = usePlusMemberDeliveryCodes;
3363
3653
  exports.usePlusMemberItemCustomAttributes = usePlusMemberItemCustomAttributes;
3654
+ exports.usePlusMemberNeedAddToCart = usePlusMemberNeedAddToCart;
3364
3655
  exports.usePlusMonthlyProductVariant = usePlusMonthlyProductVariant;
3365
3656
  exports.usePrice = usePrice;
3366
3657
  exports.useProduct = useProduct;
@@ -3379,8 +3670,15 @@ exports.useSite = useSite;
3379
3670
  exports.useUpdateCartAttributes = useUpdateCartAttributes;
3380
3671
  exports.useUpdateCartLines = useUpdateCartLines;
3381
3672
  exports.useUpdateLineCodeAmountAttributes = useUpdateLineCodeAmountAttributes;
3673
+ exports.useUpdatePlusMemberDeliveryOptions = useUpdatePlusMemberDeliveryOptions;
3382
3674
  exports.useUpdateVariantQuery = useUpdateVariantQuery;
3383
3675
  exports.useVariant = useVariant;
3384
3676
  exports.useVariantMedia = useVariantMedia;
3677
+ Object.keys(shopifySdk).forEach(function (k) {
3678
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
3679
+ enumerable: true,
3680
+ get: function () { return shopifySdk[k]; }
3681
+ });
3682
+ });
3385
3683
  //# sourceMappingURL=index.js.map
3386
3684
  //# sourceMappingURL=index.js.map