@anker-in/shopify-react 0.1.1-beta.1 → 0.1.1-beta.11
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/hooks/index.d.mts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +337 -113
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +332 -113
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-CCMIeIUh.d.ts → index-BOsx-Rx3.d.ts} +196 -64
- package/dist/{index-RevQokdZ.d.mts → index-D5VVTzBT.d.mts} +196 -64
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +360 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +355 -123
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +3 -1
- package/dist/provider/index.d.ts +3 -1
- package/dist/provider/index.js +159 -42
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +159 -42
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-CICUnw0v.d.mts → types-CUv-lzQk.d.mts} +5 -3
- package/dist/{types-CICUnw0v.d.ts → types-CUv-lzQk.d.ts} +5 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -142,6 +142,81 @@ var CODE_AMOUNT_KEY = "_sku_code_money";
|
|
|
142
142
|
var SCRIPT_CODE_AMOUNT_KEY = "_code_money";
|
|
143
143
|
var MAIN_PRODUCT_CODE = ["WS24", "WSTD", "WS7D", "WSCP", "WSPE", "WSPD"];
|
|
144
144
|
|
|
145
|
+
// src/hooks/cart/utils/normalize-add-to-cart-lines.ts
|
|
146
|
+
function normalizeAddToCartLines(lines) {
|
|
147
|
+
return lines.filter((line) => line.variant?.id).map((line, index) => {
|
|
148
|
+
const variant = line.variant;
|
|
149
|
+
const product = variant.product;
|
|
150
|
+
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;
|
|
154
|
+
return {
|
|
155
|
+
id: `temp-line-${index}-${variant.id}`,
|
|
156
|
+
// Temporary ID for pre-cart lines
|
|
157
|
+
name: product?.title || variant.title || "",
|
|
158
|
+
quantity,
|
|
159
|
+
variantId: variant.id,
|
|
160
|
+
productId: product?.id || variant.id.split("/").slice(0, -2).join("/"),
|
|
161
|
+
totalAmount,
|
|
162
|
+
subtotalAmount,
|
|
163
|
+
discountAllocations: [],
|
|
164
|
+
customAttributes: line.attributes || [],
|
|
165
|
+
variant: {
|
|
166
|
+
id: variant.id,
|
|
167
|
+
price,
|
|
168
|
+
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
169
|
+
sku: variant.sku || "",
|
|
170
|
+
name: variant.title || "",
|
|
171
|
+
image: variant.image ? {
|
|
172
|
+
url: variant.image.url,
|
|
173
|
+
altText: variant.image.altText || void 0
|
|
174
|
+
} : void 0,
|
|
175
|
+
requiresShipping: false,
|
|
176
|
+
// Default value, not available in NormalizedProductVariant
|
|
177
|
+
availableForSale: variant.availableForSale ?? true,
|
|
178
|
+
quantityAvailable: variant.quantityAvailable ?? 0,
|
|
179
|
+
currentlyNotInStock: false,
|
|
180
|
+
// Default value, will be updated when added to cart
|
|
181
|
+
weight: variant.weight,
|
|
182
|
+
metafields: variant.metafields
|
|
183
|
+
},
|
|
184
|
+
product,
|
|
185
|
+
path: product?.handle ? `/products/${product.handle}` : "",
|
|
186
|
+
discounts: [],
|
|
187
|
+
options: variant.selectedOptions?.map((opt) => ({
|
|
188
|
+
name: opt.name,
|
|
189
|
+
value: opt.value
|
|
190
|
+
}))
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function createMockCartFromLines(lines, existingCart) {
|
|
195
|
+
const normalizedLines = normalizeAddToCartLines(lines);
|
|
196
|
+
const subtotalPrice = normalizedLines.reduce((sum, line) => sum + line.subtotalAmount, 0);
|
|
197
|
+
const totalPrice = normalizedLines.reduce((sum, line) => sum + line.totalAmount, 0);
|
|
198
|
+
return {
|
|
199
|
+
id: existingCart?.id || "temp-cart-id",
|
|
200
|
+
customerId: existingCart?.customerId,
|
|
201
|
+
email: existingCart?.email,
|
|
202
|
+
createdAt: existingCart?.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
203
|
+
currency: existingCart?.currency || { code: "USD" },
|
|
204
|
+
taxesIncluded: existingCart?.taxesIncluded,
|
|
205
|
+
lineItems: normalizedLines,
|
|
206
|
+
totalLineItemsDiscount: 0,
|
|
207
|
+
orderDiscounts: 0,
|
|
208
|
+
lineItemsSubtotalPrice: subtotalPrice,
|
|
209
|
+
subtotalPrice,
|
|
210
|
+
totalPrice,
|
|
211
|
+
totalTaxAmount: 0,
|
|
212
|
+
discountCodes: existingCart?.discountCodes || [],
|
|
213
|
+
discountAllocations: [],
|
|
214
|
+
url: existingCart?.url || "",
|
|
215
|
+
ready: true,
|
|
216
|
+
customAttributes: existingCart?.customAttributes
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
145
220
|
// src/hooks/cart/utils/index.ts
|
|
146
221
|
var getQuery = () => {
|
|
147
222
|
const url = typeof window !== "undefined" ? window.location.search : "";
|
|
@@ -181,25 +256,25 @@ var getMatchedMainProductSubTotal = (cartData, variant_list, main_product) => {
|
|
|
181
256
|
return acc + (main_product?.spend_money_type === 1 /* ORIGIN_PRICE */ ? Number(line.subtotalAmount) || 0 : Number(line.totalAmount) || 0);
|
|
182
257
|
}, 0) || 0;
|
|
183
258
|
};
|
|
184
|
-
var
|
|
185
|
-
const attr = attributes.find((attr2) => attr2.key === CUSTOMER_ATTRIBUTE_KEY);
|
|
186
|
-
return safeParseJson(attr?.value ?? "") ?? {};
|
|
187
|
-
};
|
|
188
|
-
var isAttributesEqual = (attrs1 = [], attrs2 = []) => {
|
|
189
|
-
if (attrs1.length !== attrs2.length) return false;
|
|
190
|
-
const sorted1 = [...attrs1].sort((a, b) => a.key.localeCompare(b.key));
|
|
191
|
-
const sorted2 = [...attrs2].sort((a, b) => a.key.localeCompare(b.key));
|
|
192
|
-
return sorted1.every(
|
|
193
|
-
(attr, i) => attr.key === sorted2[i]?.key && attr.value === sorted2[i]?.value
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
var safeParseJson = (str) => {
|
|
259
|
+
var safeParse = (str) => {
|
|
197
260
|
try {
|
|
198
261
|
return JSON.parse(str);
|
|
199
262
|
} catch (err) {
|
|
200
263
|
return {};
|
|
201
264
|
}
|
|
202
265
|
};
|
|
266
|
+
var getDiscountEnvAttributeValue = (attributes = []) => {
|
|
267
|
+
const attr = attributes.find((attr2) => attr2.key === CUSTOMER_ATTRIBUTE_KEY);
|
|
268
|
+
return safeParse(attr?.value ?? "") ?? {};
|
|
269
|
+
};
|
|
270
|
+
var checkAttributesUpdateNeeded = (oldAttributes, newAttributes, customAttributesNeedRemove) => {
|
|
271
|
+
return oldAttributes.some((attr) => {
|
|
272
|
+
const newAttr = newAttributes.find((newAttr2) => newAttr2.key === attr.key);
|
|
273
|
+
return newAttr ? newAttr.value !== attr.value : true;
|
|
274
|
+
}) || newAttributes.some((attr) => !oldAttributes.some((oldAttr) => oldAttr.key === attr.key)) || customAttributesNeedRemove.some(
|
|
275
|
+
(removeAttr) => oldAttributes.some((oldAttr) => oldAttr.key === removeAttr.key)
|
|
276
|
+
);
|
|
277
|
+
};
|
|
203
278
|
var containsAll = (source, requiredItems = []) => {
|
|
204
279
|
if (!requiredItems?.length) return true;
|
|
205
280
|
const sourceSet = new Set(source);
|
|
@@ -366,12 +441,18 @@ var formatFunctionAutoFreeGift = ({
|
|
|
366
441
|
};
|
|
367
442
|
return result;
|
|
368
443
|
};
|
|
369
|
-
var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer) => {
|
|
444
|
+
var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
370
445
|
const tags = react.useMemo(() => customer?.tags || [], [customer?.tags]);
|
|
371
446
|
const isCustomerLoading = react.useMemo(() => !customer ? true : false, [customer]);
|
|
372
447
|
const dealsType = "";
|
|
373
448
|
const { client, locale } = useShopify();
|
|
374
449
|
const giftProductsCache = react.useRef(null);
|
|
450
|
+
const effectiveCart = react.useMemo(() => {
|
|
451
|
+
if (lines && lines.length > 0) {
|
|
452
|
+
return createMockCartFromLines(lines, cart);
|
|
453
|
+
}
|
|
454
|
+
return cart;
|
|
455
|
+
}, [lines, cart]);
|
|
375
456
|
const { activeCampaign, subtotal } = react.useMemo(() => {
|
|
376
457
|
for (const campaign of autoFreeGiftConfig) {
|
|
377
458
|
const { rule_conditions = [], rule_result } = campaign;
|
|
@@ -379,7 +460,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer) => {
|
|
|
379
460
|
const isPreCheckPassed = preCheck(rule_conditions, tags, []);
|
|
380
461
|
if (isPreCheckPassed && spend_get_reward) {
|
|
381
462
|
const matchedSubtotal = getMatchedMainProductSubTotal(
|
|
382
|
-
|
|
463
|
+
effectiveCart,
|
|
383
464
|
spend_get_reward.main_product?.variant_list?.map((v) => v.variant_id) || [],
|
|
384
465
|
{
|
|
385
466
|
spend_money_type: spend_get_reward.main_product?.spend_money_type || 1,
|
|
@@ -393,13 +474,13 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer) => {
|
|
|
393
474
|
}
|
|
394
475
|
}
|
|
395
476
|
return { activeCampaign: null, subtotal: 0 };
|
|
396
|
-
}, [autoFreeGiftConfig,
|
|
477
|
+
}, [autoFreeGiftConfig, effectiveCart, tags, dealsType]);
|
|
397
478
|
const { qualifyingGift, nextTierGoal } = react.useMemo(() => {
|
|
398
479
|
if (!activeCampaign || !activeCampaign.rule_result?.spend_get_reward?.gift_product) {
|
|
399
480
|
return { qualifyingGift: null, nextTierGoal: null };
|
|
400
481
|
}
|
|
401
482
|
const giftTiers = activeCampaign.rule_result.spend_get_reward.gift_product;
|
|
402
|
-
const qualifyingTier = [...giftTiers].
|
|
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));
|
|
403
484
|
const nextGoal = giftTiers.find((tier) => subtotal < Number(tier.spend_sum_money));
|
|
404
485
|
if (!qualifyingTier) {
|
|
405
486
|
return { qualifyingGift: null, nextTierGoal: nextGoal || null };
|
|
@@ -476,18 +557,33 @@ var useScriptAutoFreeGift = ({
|
|
|
476
557
|
campaign,
|
|
477
558
|
_giveaway,
|
|
478
559
|
cart,
|
|
479
|
-
locale: providedLocale
|
|
560
|
+
locale: providedLocale,
|
|
561
|
+
lines
|
|
480
562
|
}) => {
|
|
481
563
|
const { client, locale: contextLocale } = useShopify();
|
|
482
564
|
const locale = providedLocale || contextLocale;
|
|
483
565
|
const [points_subscribe, set_points_subscribe] = react.useState(false);
|
|
484
566
|
const giftProductsCache = react.useRef(null);
|
|
567
|
+
const effectiveCart = react.useMemo(() => {
|
|
568
|
+
if (lines && lines.length > 0) {
|
|
569
|
+
return createMockCartFromLines(lines, cart);
|
|
570
|
+
}
|
|
571
|
+
return cart;
|
|
572
|
+
}, [lines, cart]);
|
|
485
573
|
react.useEffect(() => {
|
|
486
574
|
if (locale === "au") {
|
|
487
575
|
const isPointsSubscribe = Cookies5__default.default.get("points_subscribe");
|
|
488
576
|
set_points_subscribe(!!isPointsSubscribe);
|
|
489
577
|
}
|
|
490
578
|
}, [locale]);
|
|
579
|
+
const isActivityAvailable = react.useMemo(() => {
|
|
580
|
+
if (!campaign) return false;
|
|
581
|
+
const query = getQuery();
|
|
582
|
+
const utmCampaign = Cookies5__default.default.get("utm_campaign") || query?.utm_campaign;
|
|
583
|
+
if (campaign.activityAvailableQuery && !utmCampaign?.includes(campaign.activityAvailableQuery))
|
|
584
|
+
return false;
|
|
585
|
+
return true;
|
|
586
|
+
}, [campaign]);
|
|
491
587
|
const [upgrade_multiple, upgrade_value] = react.useMemo(() => {
|
|
492
588
|
let upgrade_multiple2 = 1;
|
|
493
589
|
let upgrade_value2 = 0;
|
|
@@ -495,17 +591,17 @@ var useScriptAutoFreeGift = ({
|
|
|
495
591
|
upgrade_multiple2 = 1.2;
|
|
496
592
|
upgrade_value2 = 40;
|
|
497
593
|
}
|
|
498
|
-
|
|
594
|
+
effectiveCart?.lineItems?.forEach(({ customAttributes }) => {
|
|
499
595
|
customAttributes?.forEach(({ key, value }) => {
|
|
500
596
|
if (key === "_amount_upgrade_multiple") upgrade_multiple2 = Number(value) || 1;
|
|
501
597
|
if (key === "_amount_upgrade_value") upgrade_value2 = Number(value) || 0;
|
|
502
598
|
});
|
|
503
599
|
});
|
|
504
600
|
return [upgrade_multiple2, upgrade_value2];
|
|
505
|
-
}, [
|
|
601
|
+
}, [effectiveCart?.lineItems, points_subscribe]);
|
|
506
602
|
const breakpoints = react.useMemo(() => {
|
|
507
|
-
if (!
|
|
508
|
-
return (campaign
|
|
603
|
+
if (!isActivityAvailable) return [];
|
|
604
|
+
return (campaign?.breakpoints || []).map((item) => ({
|
|
509
605
|
breakpoint: new Decimal2__default.default(item.breakpoint).minus(new Decimal2__default.default(upgrade_value)).dividedBy(new Decimal2__default.default(upgrade_multiple)).toFixed(2, Decimal2__default.default.ROUND_DOWN),
|
|
510
606
|
giveawayProducts: item.giveawayProducts || []
|
|
511
607
|
}));
|
|
@@ -529,25 +625,26 @@ var useScriptAutoFreeGift = ({
|
|
|
529
625
|
return true;
|
|
530
626
|
}, [giftHandles]);
|
|
531
627
|
const involvedLines = react.useMemo(() => {
|
|
532
|
-
if (!
|
|
533
|
-
return (
|
|
628
|
+
if (!isActivityAvailable) return [];
|
|
629
|
+
return (effectiveCart?.lineItems || []).filter((line) => {
|
|
534
630
|
const isNotGift = line?.totalAmount && Number(line.totalAmount) > 0 && line.customAttributes?.every(
|
|
535
631
|
(item) => item.key !== _giveaway
|
|
536
632
|
);
|
|
537
633
|
const hasCampaignTag = line.product?.tags?.some(
|
|
538
|
-
(tag) => campaign
|
|
634
|
+
(tag) => campaign?.includeTags?.includes(tag.trim()) && line.variant?.availableForSale
|
|
539
635
|
);
|
|
540
636
|
return isNotGift && hasCampaignTag;
|
|
541
637
|
});
|
|
542
|
-
}, [
|
|
638
|
+
}, [effectiveCart?.lineItems, isActivityAvailable, _giveaway]);
|
|
543
639
|
const involvedSubTotal = react.useMemo(() => {
|
|
544
|
-
if (!
|
|
640
|
+
if (!isActivityAvailable) return new Decimal2__default.default(0);
|
|
545
641
|
return involvedLines.reduce((prev, item) => {
|
|
546
|
-
const amount = campaign
|
|
642
|
+
const amount = campaign?.useTotalAmount ? item.totalAmount : item.subtotalAmount;
|
|
547
643
|
return new Decimal2__default.default(prev).plus(new Decimal2__default.default(amount || 0));
|
|
548
644
|
}, new Decimal2__default.default(0));
|
|
549
|
-
}, [involvedLines,
|
|
645
|
+
}, [involvedLines, isActivityAvailable]);
|
|
550
646
|
const [freeGiftLevel, nextFreeGiftLevel] = react.useMemo(() => {
|
|
647
|
+
if (!isActivityAvailable) return [null, null];
|
|
551
648
|
const sortedLevels = [...breakpoints].sort(
|
|
552
649
|
(a, b) => Number(b.breakpoint) - Number(a.breakpoint)
|
|
553
650
|
);
|
|
@@ -691,8 +788,12 @@ var trackAddToCartGA = ({
|
|
|
691
788
|
}
|
|
692
789
|
const { variant } = lineItems[0];
|
|
693
790
|
const currencyCode = variant.product?.price?.currencyCode;
|
|
694
|
-
const
|
|
695
|
-
|
|
791
|
+
const totalPrice = lineItems?.reduce(
|
|
792
|
+
(prev, { variant: variant2 }) => prev.plus(
|
|
793
|
+
variant2?.finalPrice?.amount ?? variant2?.compareAtPrice?.amount ?? variant2?.price?.amount ?? 0
|
|
794
|
+
),
|
|
795
|
+
new Decimal2__default.default(0)
|
|
796
|
+
).toNumber();
|
|
696
797
|
gaTrack({
|
|
697
798
|
event: "ga4Event",
|
|
698
799
|
event_name: "add_to_cart",
|
|
@@ -707,7 +808,7 @@ var trackAddToCartGA = ({
|
|
|
707
808
|
item_brand: gtmParams?.brand || "",
|
|
708
809
|
item_category: variant2?.product?.productType || "",
|
|
709
810
|
item_variant: variant2?.title || variant2?.title,
|
|
710
|
-
price,
|
|
811
|
+
price: variant2?.compareAtPrice?.amount ?? variant2?.price?.amount,
|
|
711
812
|
quantity: quantity || 1
|
|
712
813
|
})),
|
|
713
814
|
...gtmParams?.ga4Params
|
|
@@ -722,9 +823,12 @@ var trackBeginCheckoutGA = ({
|
|
|
722
823
|
if (!lineItems.length) {
|
|
723
824
|
return;
|
|
724
825
|
}
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
826
|
+
const totalPrice = lineItems?.reduce(
|
|
827
|
+
(prev, { variant }) => prev.plus(
|
|
828
|
+
variant?.finalPrice?.amount ?? variant?.compareAtPrice?.amount ?? variant?.price?.amount ?? 0
|
|
829
|
+
),
|
|
830
|
+
new Decimal2__default.default(0)
|
|
831
|
+
).toNumber();
|
|
728
832
|
gaTrack({
|
|
729
833
|
event: "ga4Event",
|
|
730
834
|
event_name: "begin_checkout",
|
|
@@ -739,7 +843,7 @@ var trackBeginCheckoutGA = ({
|
|
|
739
843
|
item_brand: gtmParams?.brand || "",
|
|
740
844
|
item_category: item.variant?.product?.productType,
|
|
741
845
|
item_variant: item.variant?.title,
|
|
742
|
-
price,
|
|
846
|
+
price: item.variant?.compareAtPrice?.amount ?? item.variant?.price?.amount,
|
|
743
847
|
quantity: item.quantity || 1
|
|
744
848
|
})),
|
|
745
849
|
...gtmParams?.ga4Params
|
|
@@ -755,8 +859,12 @@ var trackBuyNowGA = ({
|
|
|
755
859
|
}
|
|
756
860
|
const { variant } = lineItems[0];
|
|
757
861
|
const currencyCode = variant.price?.currencyCode;
|
|
758
|
-
const
|
|
759
|
-
|
|
862
|
+
const totalPrice = lineItems?.reduce(
|
|
863
|
+
(prev, { variant: variant2 }) => prev.plus(
|
|
864
|
+
variant2?.finalPrice?.amount ?? variant2?.compareAtPrice?.amount ?? (variant2?.price?.amount || 0)
|
|
865
|
+
),
|
|
866
|
+
new Decimal2__default.default(0)
|
|
867
|
+
).toNumber();
|
|
760
868
|
gaTrack({
|
|
761
869
|
event: "ga4Event",
|
|
762
870
|
event_name: "begin_checkout",
|
|
@@ -771,7 +879,7 @@ var trackBuyNowGA = ({
|
|
|
771
879
|
item_brand: gtmParams?.brand || "",
|
|
772
880
|
item_category: item.variant?.product?.productType || "",
|
|
773
881
|
item_variant: item.variant?.title,
|
|
774
|
-
price,
|
|
882
|
+
price: item.variant?.compareAtPrice?.amount ?? item.variant?.price?.amount,
|
|
775
883
|
quantity: item.quantity || 1
|
|
776
884
|
})),
|
|
777
885
|
...gtmParams?.ga4Params
|
|
@@ -914,6 +1022,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
914
1022
|
if (!resultCart) {
|
|
915
1023
|
return void 0;
|
|
916
1024
|
}
|
|
1025
|
+
console.log("npm addCartLines resultCart", resultCart);
|
|
917
1026
|
if (resultCart.discountCodes && resultCart.discountCodes.length > 0) {
|
|
918
1027
|
const unapplicableCodes = resultCart.discountCodes.filter((item) => !item.applicable).map((item) => item.code);
|
|
919
1028
|
if (unapplicableCodes.length > 0) {
|
|
@@ -1087,6 +1196,60 @@ function useBuyNow({ withTrack = true } = {}, swrOptions) {
|
|
|
1087
1196
|
);
|
|
1088
1197
|
return useSWRMutation__default.default("buy-now", buyNow, swrOptions);
|
|
1089
1198
|
}
|
|
1199
|
+
function useCalcGiftsFromLines({
|
|
1200
|
+
lines,
|
|
1201
|
+
customer,
|
|
1202
|
+
scriptGiveawayKey = CUSTOMER_SCRIPT_GIFT_KEY
|
|
1203
|
+
}) {
|
|
1204
|
+
const { locale } = useShopify();
|
|
1205
|
+
const { cart, autoFreeGiftConfig, gradientGiftsConfig } = useCartContext();
|
|
1206
|
+
const functionGift = useCalcAutoFreeGift(cart, autoFreeGiftConfig || [], customer, lines);
|
|
1207
|
+
const scriptGift = useScriptAutoFreeGift({
|
|
1208
|
+
campaign: gradientGiftsConfig || null,
|
|
1209
|
+
_giveaway: scriptGiveawayKey,
|
|
1210
|
+
cart,
|
|
1211
|
+
locale,
|
|
1212
|
+
lines
|
|
1213
|
+
});
|
|
1214
|
+
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
|
|
1219
|
+
);
|
|
1220
|
+
const variant = giftProduct?.variants?.[0];
|
|
1221
|
+
return {
|
|
1222
|
+
variant: {
|
|
1223
|
+
id: variant?.id || "",
|
|
1224
|
+
handle: product.handle,
|
|
1225
|
+
sku: product.sku
|
|
1226
|
+
},
|
|
1227
|
+
quantity: 1,
|
|
1228
|
+
attributes: [
|
|
1229
|
+
{
|
|
1230
|
+
key: scriptGiveawayKey,
|
|
1231
|
+
value: "true"
|
|
1232
|
+
}
|
|
1233
|
+
]
|
|
1234
|
+
};
|
|
1235
|
+
}).filter((item) => item.variant.id) : [];
|
|
1236
|
+
return [...functionGiftLines, ...scriptGiftLines];
|
|
1237
|
+
}, [
|
|
1238
|
+
functionGift.qualifyingGift,
|
|
1239
|
+
scriptGift.freeGiftLevel,
|
|
1240
|
+
scriptGift.giftProductsResult,
|
|
1241
|
+
scriptGiveawayKey
|
|
1242
|
+
]);
|
|
1243
|
+
const hasGifts = react.useMemo(() => {
|
|
1244
|
+
return allGiftLines.length > 0;
|
|
1245
|
+
}, [allGiftLines]);
|
|
1246
|
+
return {
|
|
1247
|
+
functionGift,
|
|
1248
|
+
scriptGift,
|
|
1249
|
+
allGiftLines,
|
|
1250
|
+
hasGifts
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1090
1253
|
|
|
1091
1254
|
// src/hooks/cart/types/order-discount.ts
|
|
1092
1255
|
var OrderDiscountType = /* @__PURE__ */ ((OrderDiscountType2) => {
|
|
@@ -1236,8 +1399,6 @@ var useCartAttributes = ({
|
|
|
1236
1399
|
memberSetting,
|
|
1237
1400
|
cart
|
|
1238
1401
|
});
|
|
1239
|
-
console.log("memberSetting", memberSetting);
|
|
1240
|
-
console.log("hasPlusMember", hasPlusMember);
|
|
1241
1402
|
react.useEffect(() => {
|
|
1242
1403
|
setCurrentUrl(window.location.href);
|
|
1243
1404
|
}, []);
|
|
@@ -1263,7 +1424,7 @@ var useCartAttributes = ({
|
|
|
1263
1424
|
return "new_user_login";
|
|
1264
1425
|
}, [customer]);
|
|
1265
1426
|
const memberAttributes = react.useMemo(() => {
|
|
1266
|
-
|
|
1427
|
+
const attributes = [
|
|
1267
1428
|
{
|
|
1268
1429
|
key: "_token",
|
|
1269
1430
|
value: profile?.token
|
|
@@ -1282,19 +1443,34 @@ var useCartAttributes = ({
|
|
|
1282
1443
|
{
|
|
1283
1444
|
key: "_is_login",
|
|
1284
1445
|
value: profile?.token ? "true" : "false"
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
key: "_last_url",
|
|
1449
|
+
value: typeof window !== "undefined" ? window.location.origin + window.location.pathname : ""
|
|
1285
1450
|
}
|
|
1286
1451
|
];
|
|
1452
|
+
if (profile?.token) {
|
|
1453
|
+
attributes.push({
|
|
1454
|
+
key: "_login_user",
|
|
1455
|
+
value: "1"
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
return attributes;
|
|
1287
1459
|
}, [profile?.memberType, profile?.token, userType, hasPlusMember]);
|
|
1288
1460
|
const functionAttributes = react.useMemo(() => {
|
|
1289
|
-
|
|
1290
|
-
|
|
1461
|
+
const hasFunctionEnvAttribute = cart?.lineItems.some(
|
|
1462
|
+
(item) => item.customAttributes?.some((attr) => attr.key === CUSTOMER_ATTRIBUTE_KEY)
|
|
1463
|
+
);
|
|
1464
|
+
const discountCodes = cart?.discountCodes.map((item) => item.code).filter((code) => code) || [];
|
|
1465
|
+
return hasFunctionEnvAttribute ? [
|
|
1466
|
+
{
|
|
1291
1467
|
key: "_discounts_function_env",
|
|
1292
1468
|
value: JSON.stringify({
|
|
1293
|
-
discount_code:
|
|
1469
|
+
discount_code: discountCodes,
|
|
1294
1470
|
user_tags: customer?.tags || []
|
|
1295
1471
|
})
|
|
1296
1472
|
}
|
|
1297
|
-
];
|
|
1473
|
+
] : [];
|
|
1298
1474
|
}, [cart]);
|
|
1299
1475
|
const presellAttributes = react.useMemo(() => {
|
|
1300
1476
|
return [
|
|
@@ -2471,6 +2647,69 @@ var usePlusMemberDeliveryCodes = ({
|
|
|
2471
2647
|
[deliveryData]
|
|
2472
2648
|
);
|
|
2473
2649
|
};
|
|
2650
|
+
function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
|
|
2651
|
+
const { client, locale, cartCookieAdapter } = useShopify();
|
|
2652
|
+
const updateDeliveryOptions = react.useCallback(
|
|
2653
|
+
async (_key, { arg }) => {
|
|
2654
|
+
const updatedCart = await shopifySdk.updateCartDeliveryOptions(client, {
|
|
2655
|
+
...arg,
|
|
2656
|
+
metafieldIdentifiers,
|
|
2657
|
+
cookieAdapter: cartCookieAdapter
|
|
2658
|
+
});
|
|
2659
|
+
console.log("useUpdateCartDeliveryOptions updatedCart", updatedCart);
|
|
2660
|
+
if (updatedCart) {
|
|
2661
|
+
mutate(updatedCart);
|
|
2662
|
+
}
|
|
2663
|
+
return updatedCart;
|
|
2664
|
+
},
|
|
2665
|
+
[client, locale, cartCookieAdapter, mutate]
|
|
2666
|
+
);
|
|
2667
|
+
return useSWRMutation__default.default("update-cart-delivery-options", updateDeliveryOptions, options);
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
// src/hooks/member/plus/use-update-plus-member-delivery-options.ts
|
|
2671
|
+
var useUpdatePlusMemberDeliveryOptions = ({
|
|
2672
|
+
options
|
|
2673
|
+
}) => {
|
|
2674
|
+
const { cart, mutateCart: mutate, metafieldIdentifiers } = useCartContext();
|
|
2675
|
+
const { trigger: updateCartDeliveryOptions2, isMutating } = useUpdateCartDeliveryOptions(
|
|
2676
|
+
mutate,
|
|
2677
|
+
metafieldIdentifiers
|
|
2678
|
+
);
|
|
2679
|
+
const handler = react.useCallback(
|
|
2680
|
+
async (_, { arg }) => {
|
|
2681
|
+
const { deliveryData } = arg;
|
|
2682
|
+
const firstDeliveryGroup = cart?.deliveryGroups?.[0];
|
|
2683
|
+
const deliveryGroupId = firstDeliveryGroup?.id;
|
|
2684
|
+
const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option?.code;
|
|
2685
|
+
if (!deliveryGroupId || !selectedOptionCode || selectedOptionCode === firstDeliveryGroup?.selectedDeliveryOption?.code) {
|
|
2686
|
+
return null;
|
|
2687
|
+
}
|
|
2688
|
+
const deliveryGroup = cart?.deliveryGroups?.find((group) => group?.id === deliveryGroupId);
|
|
2689
|
+
const matchedOption = deliveryGroup?.deliveryOptions?.find(
|
|
2690
|
+
(option) => option?.code === selectedOptionCode
|
|
2691
|
+
);
|
|
2692
|
+
if (!matchedOption?.handle) {
|
|
2693
|
+
return null;
|
|
2694
|
+
}
|
|
2695
|
+
const deliveryOptions = [
|
|
2696
|
+
{
|
|
2697
|
+
deliveryGroupId,
|
|
2698
|
+
deliveryOptionHandle: matchedOption.handle
|
|
2699
|
+
}
|
|
2700
|
+
];
|
|
2701
|
+
const updatedCart = await updateCartDeliveryOptions2({
|
|
2702
|
+
selectedDeliveryOptions: deliveryOptions
|
|
2703
|
+
});
|
|
2704
|
+
if (updatedCart && mutate) {
|
|
2705
|
+
mutate(updatedCart);
|
|
2706
|
+
}
|
|
2707
|
+
return updatedCart;
|
|
2708
|
+
},
|
|
2709
|
+
[cart, updateCartDeliveryOptions2, mutate]
|
|
2710
|
+
);
|
|
2711
|
+
return useSWRMutation__default.default("update-cart-delivery-options", handler, options);
|
|
2712
|
+
};
|
|
2474
2713
|
var usePlusMemberItemCustomAttributes = ({
|
|
2475
2714
|
deliveryData
|
|
2476
2715
|
}) => {
|
|
@@ -2490,48 +2729,12 @@ var usePlusMemberCheckoutCustomAttributes = ({
|
|
|
2490
2729
|
deliveryData,
|
|
2491
2730
|
product,
|
|
2492
2731
|
variant,
|
|
2493
|
-
customer,
|
|
2494
2732
|
isShowShippingBenefits
|
|
2495
2733
|
}) => {
|
|
2496
2734
|
const { deliveryCustomData } = deliveryData || {};
|
|
2497
2735
|
const { profile } = usePlusMemberContext();
|
|
2498
|
-
const userType = react.useMemo(() => {
|
|
2499
|
-
const customerInfo = customer;
|
|
2500
|
-
if (!customerInfo) {
|
|
2501
|
-
return "new_user_unlogin";
|
|
2502
|
-
}
|
|
2503
|
-
if (customer) {
|
|
2504
|
-
const { orders = {} } = customer;
|
|
2505
|
-
const edgesLength = orders?.edges?.length;
|
|
2506
|
-
if (edgesLength === 1) {
|
|
2507
|
-
return "old_user_orders_once";
|
|
2508
|
-
} else if (edgesLength && edgesLength > 1) {
|
|
2509
|
-
return "old_user_orders_twice";
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
return "new_user_login";
|
|
2513
|
-
}, [customer]);
|
|
2514
2736
|
return react.useMemo(() => {
|
|
2515
|
-
const checkoutCustomAttributes = [
|
|
2516
|
-
{
|
|
2517
|
-
key: "_token",
|
|
2518
|
-
value: profile?.token || ""
|
|
2519
|
-
},
|
|
2520
|
-
{
|
|
2521
|
-
key: "_last_url",
|
|
2522
|
-
value: typeof window !== "undefined" ? window.location.origin + window.location.pathname : ""
|
|
2523
|
-
},
|
|
2524
|
-
{
|
|
2525
|
-
key: "_user_type",
|
|
2526
|
-
value: userType
|
|
2527
|
-
}
|
|
2528
|
-
];
|
|
2529
|
-
if (profile) {
|
|
2530
|
-
checkoutCustomAttributes.push({
|
|
2531
|
-
key: "_login_user",
|
|
2532
|
-
value: "1"
|
|
2533
|
-
});
|
|
2534
|
-
}
|
|
2737
|
+
const checkoutCustomAttributes = [];
|
|
2535
2738
|
if (deliveryCustomData) {
|
|
2536
2739
|
checkoutCustomAttributes.push({
|
|
2537
2740
|
key: "_checkout_delivery_custom",
|
|
@@ -2541,12 +2744,6 @@ var usePlusMemberCheckoutCustomAttributes = ({
|
|
|
2541
2744
|
})
|
|
2542
2745
|
});
|
|
2543
2746
|
}
|
|
2544
|
-
if (variant?.metafields?.presell) {
|
|
2545
|
-
checkoutCustomAttributes.push({
|
|
2546
|
-
key: "_presale",
|
|
2547
|
-
value: "true"
|
|
2548
|
-
});
|
|
2549
|
-
}
|
|
2550
2747
|
if (isShowShippingBenefits && !isShowShippingBenefits({ variant, product, setting: {} })) {
|
|
2551
2748
|
checkoutCustomAttributes.push({
|
|
2552
2749
|
key: "_hide_shipping",
|
|
@@ -2554,18 +2751,17 @@ var usePlusMemberCheckoutCustomAttributes = ({
|
|
|
2554
2751
|
});
|
|
2555
2752
|
}
|
|
2556
2753
|
return checkoutCustomAttributes;
|
|
2557
|
-
}, [deliveryCustomData, product, profile,
|
|
2754
|
+
}, [deliveryCustomData, product, profile, variant, isShowShippingBenefits]);
|
|
2558
2755
|
};
|
|
2559
2756
|
function useAutoRemovePlusMemberInCart({
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2757
|
+
cart,
|
|
2758
|
+
profile,
|
|
2759
|
+
memberSetting
|
|
2563
2760
|
}) {
|
|
2564
|
-
const { plus_monthly_product, plus_annual_product } =
|
|
2565
|
-
const { cart } = useCartContext();
|
|
2761
|
+
const { plus_monthly_product, plus_annual_product } = memberSetting || {};
|
|
2566
2762
|
const { trigger: removeCartLines2 } = useRemoveCartLines();
|
|
2567
2763
|
react.useEffect(() => {
|
|
2568
|
-
if (!cart) return;
|
|
2764
|
+
if (!cart || !plus_monthly_product || !plus_annual_product) return;
|
|
2569
2765
|
const removePlusProduct = async (productType) => {
|
|
2570
2766
|
if (!productType) return;
|
|
2571
2767
|
const product = cart.lineItems?.find(
|
|
@@ -2577,26 +2773,53 @@ function useAutoRemovePlusMemberInCart({
|
|
|
2577
2773
|
});
|
|
2578
2774
|
}
|
|
2579
2775
|
};
|
|
2580
|
-
if (isMonthlyPlus) {
|
|
2776
|
+
if (profile?.isMonthlyPlus) {
|
|
2581
2777
|
removePlusProduct(plus_monthly_product);
|
|
2582
2778
|
}
|
|
2583
|
-
if (isAnnualPlus) {
|
|
2779
|
+
if (profile?.isAnnualPlus) {
|
|
2584
2780
|
removePlusProduct(plus_annual_product);
|
|
2585
2781
|
}
|
|
2782
|
+
}, [cart, plus_annual_product, plus_monthly_product, profile, removeCartLines2]);
|
|
2783
|
+
}
|
|
2784
|
+
function useAddPlusMemberProductsToCart({
|
|
2785
|
+
cart,
|
|
2786
|
+
profile
|
|
2787
|
+
}) {
|
|
2788
|
+
const { selectedPlusMemberMode, selectedPlusMemberProduct, plusMemberMetafields } = usePlusMemberContext();
|
|
2789
|
+
const { hasMonthlyPlus, hasAnnualPlus } = useHasPlusMemberInCart({
|
|
2790
|
+
memberSetting: plusMemberMetafields,
|
|
2791
|
+
cart
|
|
2792
|
+
});
|
|
2793
|
+
const plusMemberProduct = react.useMemo(() => {
|
|
2794
|
+
if (!selectedPlusMemberProduct || selectedPlusMemberMode === "free" /* FREE */) {
|
|
2795
|
+
return void 0;
|
|
2796
|
+
}
|
|
2797
|
+
if (selectedPlusMemberMode === "monthly" /* MONTHLY */ && hasMonthlyPlus) {
|
|
2798
|
+
return void 0;
|
|
2799
|
+
}
|
|
2800
|
+
if (selectedPlusMemberMode === "annual" /* ANNUAL */ && hasAnnualPlus) {
|
|
2801
|
+
return void 0;
|
|
2802
|
+
}
|
|
2803
|
+
if (profile?.isMonthlyPlus && selectedPlusMemberMode === "monthly" /* MONTHLY */) {
|
|
2804
|
+
return void 0;
|
|
2805
|
+
}
|
|
2806
|
+
if (!profile?.isAnnualPlus && selectedPlusMemberMode === "annual" /* ANNUAL */) {
|
|
2807
|
+
return void 0;
|
|
2808
|
+
}
|
|
2809
|
+
return selectedPlusMemberProduct;
|
|
2586
2810
|
}, [
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
removeCartLines2
|
|
2811
|
+
selectedPlusMemberMode,
|
|
2812
|
+
selectedPlusMemberProduct?.variant,
|
|
2813
|
+
selectedPlusMemberProduct?.product,
|
|
2814
|
+
hasMonthlyPlus,
|
|
2815
|
+
hasAnnualPlus
|
|
2593
2816
|
]);
|
|
2817
|
+
return plusMemberProduct;
|
|
2594
2818
|
}
|
|
2595
2819
|
var PlusMemberProvider = ({
|
|
2596
2820
|
variant,
|
|
2597
2821
|
product,
|
|
2598
|
-
|
|
2599
|
-
metafields,
|
|
2822
|
+
memberSetting,
|
|
2600
2823
|
initialSelectedPlusMemberMode = "free",
|
|
2601
2824
|
profile,
|
|
2602
2825
|
locale,
|
|
@@ -2616,14 +2839,14 @@ var PlusMemberProvider = ({
|
|
|
2616
2839
|
const [deleteMarginBottom, setDeleteMarginBottom] = react.useState(false);
|
|
2617
2840
|
const shippingMethodsContext = useShippingMethods({
|
|
2618
2841
|
variant,
|
|
2619
|
-
plusMemberMetafields:
|
|
2842
|
+
plusMemberMetafields: memberSetting,
|
|
2620
2843
|
selectedPlusMemberMode});
|
|
2621
2844
|
const plusMemberHandles = react.useMemo(() => {
|
|
2622
2845
|
return [
|
|
2623
|
-
|
|
2624
|
-
|
|
2846
|
+
memberSetting?.plus_monthly_product?.handle,
|
|
2847
|
+
memberSetting?.plus_annual_product?.handle
|
|
2625
2848
|
].filter(Boolean);
|
|
2626
|
-
}, [
|
|
2849
|
+
}, [memberSetting]);
|
|
2627
2850
|
const { data: plusMemberProducts = [] } = useProductsByHandles({
|
|
2628
2851
|
handles: plusMemberHandles
|
|
2629
2852
|
});
|
|
@@ -2631,25 +2854,24 @@ var PlusMemberProvider = ({
|
|
|
2631
2854
|
if (selectedPlusMemberMode === "free" /* FREE */) {
|
|
2632
2855
|
return null;
|
|
2633
2856
|
}
|
|
2634
|
-
const handle = selectedPlusMemberMode === "monthly" /* MONTHLY */ ?
|
|
2635
|
-
const sku = selectedPlusMemberMode === "monthly" /* MONTHLY */ ?
|
|
2857
|
+
const handle = selectedPlusMemberMode === "monthly" /* MONTHLY */ ? memberSetting?.plus_monthly_product?.handle : memberSetting?.plus_annual_product?.handle;
|
|
2858
|
+
const sku = selectedPlusMemberMode === "monthly" /* MONTHLY */ ? memberSetting?.plus_monthly_product?.sku : memberSetting?.plus_annual_product?.sku;
|
|
2636
2859
|
const product2 = plusMemberProducts?.find((p) => p.handle === handle);
|
|
2637
2860
|
const variant2 = product2?.variants?.find((v) => v.sku === sku);
|
|
2638
2861
|
return product2 && variant2 ? { product: product2, variant: variant2 } : null;
|
|
2639
|
-
}, [plusMemberProducts,
|
|
2862
|
+
}, [plusMemberProducts, memberSetting, selectedPlusMemberMode]);
|
|
2640
2863
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2641
2864
|
PlusMemberContext.Provider,
|
|
2642
2865
|
{
|
|
2643
2866
|
value: {
|
|
2644
2867
|
variant,
|
|
2645
|
-
shopCommon,
|
|
2646
2868
|
zipCode,
|
|
2647
2869
|
setZipCode,
|
|
2648
2870
|
allowNextDayDelivery,
|
|
2649
2871
|
setAllowNextDayDelivery,
|
|
2650
2872
|
allowThirdDayDelivery,
|
|
2651
2873
|
setAllowThirdDayDelivery,
|
|
2652
|
-
plusMemberMetafields:
|
|
2874
|
+
plusMemberMetafields: memberSetting,
|
|
2653
2875
|
selectedPlusMemberMode,
|
|
2654
2876
|
setSelectedPlusMemberMode,
|
|
2655
2877
|
showAreaCheckModal,
|
|
@@ -2868,6 +3090,9 @@ function CartProvider({
|
|
|
2868
3090
|
}) {
|
|
2869
3091
|
const { client, cartCookieAdapter } = useShopify();
|
|
2870
3092
|
const [customAttributes, setCustomAttributes] = react.useState([]);
|
|
3093
|
+
const [customAttributesNeedDelete, setCustomAttributesNeedDelete] = react.useState(
|
|
3094
|
+
[]
|
|
3095
|
+
);
|
|
2871
3096
|
const [isCodeChanging, setIsCodeChanging] = react.useState(false);
|
|
2872
3097
|
const [loadingState, setLoadingState] = react.useState({
|
|
2873
3098
|
editLineQuantityLoading: false,
|
|
@@ -2898,7 +3123,11 @@ function CartProvider({
|
|
|
2898
3123
|
ahooks.useRequest(
|
|
2899
3124
|
() => {
|
|
2900
3125
|
const newAttributes = [...attributes, ...customAttributes];
|
|
2901
|
-
const needUpdate = cart && !
|
|
3126
|
+
const needUpdate = cart && !checkAttributesUpdateNeeded(
|
|
3127
|
+
cart.customAttributes,
|
|
3128
|
+
newAttributes,
|
|
3129
|
+
customAttributesNeedDelete
|
|
3130
|
+
);
|
|
2902
3131
|
if (needUpdate) {
|
|
2903
3132
|
return updateAttributes({ attributes: newAttributes });
|
|
2904
3133
|
} else {
|
|
@@ -2919,11 +3148,12 @@ function CartProvider({
|
|
|
2919
3148
|
isCartLoading: isCartLoading || isCodeChanging,
|
|
2920
3149
|
setLoadingState
|
|
2921
3150
|
});
|
|
2922
|
-
const removeCustomAttributes = react.useCallback(
|
|
2923
|
-
|
|
2924
|
-
(
|
|
2925
|
-
|
|
2926
|
-
|
|
3151
|
+
const removeCustomAttributes = react.useCallback(
|
|
3152
|
+
(attributes2) => {
|
|
3153
|
+
setCustomAttributesNeedDelete(attributes2);
|
|
3154
|
+
},
|
|
3155
|
+
[setCustomAttributesNeedDelete]
|
|
3156
|
+
);
|
|
2927
3157
|
const addCustomAttributes = react.useCallback(
|
|
2928
3158
|
(attributes2) => {
|
|
2929
3159
|
const sameAttributes = attributes2.filter(
|
|
@@ -3010,6 +3240,7 @@ function CartProvider({
|
|
|
3010
3240
|
isCodeChanging,
|
|
3011
3241
|
setIsCodeChanging,
|
|
3012
3242
|
autoFreeGiftConfig,
|
|
3243
|
+
gradientGiftsConfig,
|
|
3013
3244
|
setLoadingState,
|
|
3014
3245
|
loadingState,
|
|
3015
3246
|
// function满赠
|
|
@@ -3033,6 +3264,7 @@ function CartProvider({
|
|
|
3033
3264
|
locale,
|
|
3034
3265
|
isCodeChanging,
|
|
3035
3266
|
autoFreeGiftConfig,
|
|
3267
|
+
gradientGiftsConfig,
|
|
3036
3268
|
loadingState,
|
|
3037
3269
|
// function满赠
|
|
3038
3270
|
functionAutoFreeGift,
|
|
@@ -3105,7 +3337,9 @@ exports.atobID = atobID;
|
|
|
3105
3337
|
exports.browserCartCookieAdapter = browserCartCookieAdapter;
|
|
3106
3338
|
exports.browserCookieAdapter = browserCookieAdapter;
|
|
3107
3339
|
exports.btoaID = btoaID;
|
|
3340
|
+
exports.checkAttributesUpdateNeeded = checkAttributesUpdateNeeded;
|
|
3108
3341
|
exports.clearGeoLocationCache = clearGeoLocationCache;
|
|
3342
|
+
exports.createMockCartFromLines = createMockCartFromLines;
|
|
3109
3343
|
exports.currencyCodeMapping = currencyCodeMapping;
|
|
3110
3344
|
exports.defaultSWRMutationConfiguration = defaultSWRMutationConfiguration;
|
|
3111
3345
|
exports.formatFunctionAutoFreeGift = formatFunctionAutoFreeGift;
|
|
@@ -3116,15 +3350,16 @@ exports.getDiscountEnvAttributeValue = getDiscountEnvAttributeValue;
|
|
|
3116
3350
|
exports.getMatchedMainProductSubTotal = getMatchedMainProductSubTotal;
|
|
3117
3351
|
exports.getQuery = getQuery;
|
|
3118
3352
|
exports.getReferralAttributes = getReferralAttributes;
|
|
3119
|
-
exports.
|
|
3353
|
+
exports.normalizeAddToCartLines = normalizeAddToCartLines;
|
|
3120
3354
|
exports.preCheck = preCheck;
|
|
3121
|
-
exports.
|
|
3355
|
+
exports.safeParse = safeParse;
|
|
3122
3356
|
exports.trackAddToCartFBQ = trackAddToCartFBQ;
|
|
3123
3357
|
exports.trackAddToCartGA = trackAddToCartGA;
|
|
3124
3358
|
exports.trackBeginCheckoutGA = trackBeginCheckoutGA;
|
|
3125
3359
|
exports.trackBuyNowFBQ = trackBuyNowFBQ;
|
|
3126
3360
|
exports.trackBuyNowGA = trackBuyNowGA;
|
|
3127
3361
|
exports.useAddCartLines = useAddCartLines;
|
|
3362
|
+
exports.useAddPlusMemberProductsToCart = useAddPlusMemberProductsToCart;
|
|
3128
3363
|
exports.useAddToCart = useAddToCart;
|
|
3129
3364
|
exports.useAllBlogs = useAllBlogs;
|
|
3130
3365
|
exports.useAllCollections = useAllCollections;
|
|
@@ -3137,6 +3372,7 @@ exports.useAutoRemovePlusMemberInCart = useAutoRemovePlusMemberInCart;
|
|
|
3137
3372
|
exports.useBlog = useBlog;
|
|
3138
3373
|
exports.useBuyNow = useBuyNow;
|
|
3139
3374
|
exports.useCalcAutoFreeGift = useCalcAutoFreeGift;
|
|
3375
|
+
exports.useCalcGiftsFromLines = useCalcGiftsFromLines;
|
|
3140
3376
|
exports.useCalcOrderDiscount = useCalcOrderDiscount;
|
|
3141
3377
|
exports.useCartAttributes = useCartAttributes;
|
|
3142
3378
|
exports.useCartContext = useCartContext;
|
|
@@ -3171,6 +3407,7 @@ exports.useSite = useSite;
|
|
|
3171
3407
|
exports.useUpdateCartAttributes = useUpdateCartAttributes;
|
|
3172
3408
|
exports.useUpdateCartLines = useUpdateCartLines;
|
|
3173
3409
|
exports.useUpdateLineCodeAmountAttributes = useUpdateLineCodeAmountAttributes;
|
|
3410
|
+
exports.useUpdatePlusMemberDeliveryOptions = useUpdatePlusMemberDeliveryOptions;
|
|
3174
3411
|
exports.useUpdateVariantQuery = useUpdateVariantQuery;
|
|
3175
3412
|
exports.useVariant = useVariant;
|
|
3176
3413
|
exports.useVariantMedia = useVariantMedia;
|