@anker-in/shopify-react 0.1.1-beta.2 → 0.1.1-beta.21

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.
@@ -1,9 +1,1899 @@
1
- export { A as AddCartLinesInput, d as ApplyCartCodesInput, s as AutoFreeGift, v as AutoFreeGiftConfig, L as AutoFreeGiftItem, N as AutoFreeGiftList, t as AutoFreeGiftMainProduct, B as BuyNowInput, H as BuyRuleType, a2 as CODE_AMOUNT_KEY, a0 as CUSTOMER_ATTRIBUTE_KEY, a1 as CUSTOMER_SCRIPT_GIFT_KEY, K as CartLineInput, x as Config, C as CreateCartInput, b8 as Customer, b7 as CustomerOrder, D as DiscountLabel, J as FormattedGift, I as FunctionGiftResult, bn as GeoLocationData, G as GiftProduct, E as GiftProductItem, y as GiftTier, bd as HasPlusMemberInCartResult, au as ImageMedia, bo as LocaleMapping, a4 as MAIN_PRODUCT_CODE, M as MainProductInfo, an as Options, Q as OrderBasePriceType, W as OrderDiscountConfig, O as OrderDiscountResult, P as OrderDiscountType, aY as PlusMemberContext, aX as PlusMemberContextValue, bi as PlusMemberProvider, bh as PlusMemberProviderProps, Y as PriceBasePriceType, Z as PriceDiscountConfig, X as PriceDiscountType, f as RemoveCartCodesInput, R as RemoveCartLinesInput, z as RewardItem, w as RuleCondition, F as RuleType, a3 as SCRIPT_CODE_AMOUNT_KEY, aQ as SearchResult, aP as SearchResultItem, aO as SearchResultType, ag as SelectedOptionsResult, aW as ShippingMethodsContext, aT as SiteInfo, S as SpendMoneyType, T as TieredDiscount, U as UpdateCartAttributesInput, bf as UseAddPlusMemberProductsToCartProps, aG as UseAllBlogsOptions, aA as UseAllCollectionsOptions, aj as UseAllProductsOptions, aI as UseArticleOptions, aM as UseArticlesInBlogOptions, aK as UseArticlesOptions, ba as UseAutoRemovePlusMemberInCartProps, aE as UseBlogOptions, i as UseBuyNowOptions, ay as UseCollectionOptions, aC as UseCollectionsOptions, bl as UseExposureOptions, bp as UseGeoLocationOptions, bc as UseHasPlusMemberInCartProps, bj as UseIntersectionOptions, ap as UsePriceOptions, aq as UsePriceResult, ah as UseProductOptions, al as UseProductsByHandlesOptions, p as UseScriptAutoFreeGiftResult, aR as UseSearchOptions, b0 as UseShippingMethodsOptions, b1 as UseShippingMethodsResult, aU as UseSiteOptions, V as VariantItem, aw as VariantMedia, av as VideoMedia, a6 as atobID, a7 as btoaID, ab as checkAttributesUpdateNeeded, bs as clearGeoLocationCache, _ as currencyCodeMapping, $ as defaultSWRMutationConfiguration, ae as formatFunctionAutoFreeGift, ad as formatScriptAutoFreeGift, br as getCachedGeoLocation, aa as getDiscountEnvAttributeValue, a8 as getMatchedMainProductSubTotal, a5 as getQuery, m as getReferralAttributes, ac as preCheck, a9 as safeParse, a as useAddCartLines, bg as useAddPlusMemberProductsToCart, aH as useAllBlogs, aB as useAllCollections, ak as useAllProducts, e as useApplyCartCodes, aJ as useArticle, aL as useArticles, aN as useArticlesInBlog, bb as useAutoRemovePlusMemberInCart, aF as useBlog, j as useBuyNow, k as useCalcAutoFreeGift, l as useCalcOrderDiscount, n as useCartAttributes, o as useCartItemQuantityLimit, az as useCollection, aD as useCollections, u as useCreateCart, bm as useExposure, bq as useGeoLocation, be as useHasPlusMemberInCart, bk as useIntersection, a$ as usePlusAnnualProductVariant, b9 as usePlusMemberCheckoutCustomAttributes, aZ as usePlusMemberContext, b5 as usePlusMemberDeliveryCodes, b6 as usePlusMemberItemCustomAttributes, a_ as usePlusMonthlyProductVariant, ar as usePrice, ai as useProduct, as as useProductUrl, am as useProductsByHandles, g as useRemoveCartCodes, c as useRemoveCartLines, b4 as useReplaceCartPlusMember, q as useScriptAutoFreeGift, aS as useSearch, af as useSelectedOptions, b3 as useShippingMethodAvailableCheck, b2 as useShippingMethods, aV as useSite, h as useUpdateCartAttributes, b as useUpdateCartLines, r as useUpdateLineCodeAmountAttributes, at as useUpdateVariantQuery, ao as useVariant, ax as useVariantMedia } from '../index-Bea95u2X.mjs';
2
- export { a as AddToCartInput, A as AddToCartLineItem, h as DeliveryCustomData, i as DeliveryData, g as DeliveryOption, D as DeliveryPlusType, M as MailingAddress, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, c as PlusMemberShippingMethodMetafields, f as SelectedPlusMemberProduct, S as ShippingMethodMode, U as UseAddToCartOptions, u as useAddToCart } from '../types-CICUnw0v.mjs';
3
- import 'swr/mutation';
4
- import '@anker-in/shopify-sdk';
5
- import 'decimal.js';
6
- import 'swr';
7
- import 'swr/_internal';
8
- import 'react';
9
- import 'react/jsx-runtime';
1
+ import * as swr_mutation from 'swr/mutation';
2
+ import { SWRMutationConfiguration } from 'swr/mutation';
3
+ import * as _anker_in_shopify_sdk from '@anker-in/shopify-sdk';
4
+ import { CartLineInput, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, NormalizedAttribute, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
5
+ import { A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, d as PlusMemberShippingMethodConfig, e as PlusMemberSettingsMetafields, D as DeliveryPlusType, f as SelectedPlusMemberProduct, h as DeliveryData } from '../types-C1So3siD.mjs';
6
+ export { a as AddToCartInput, g as DeliveryCustomData, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, c as PlusMemberShippingMethodMetafields, S as ShippingMethodMode, U as UseAddToCartOptions, u as useAddToCart } from '../types-C1So3siD.mjs';
7
+ import Decimal from 'decimal.js';
8
+ import * as swr from 'swr';
9
+ import swr__default, { SWRConfiguration } from 'swr';
10
+ import * as swr__internal from 'swr/_internal';
11
+ import * as React$1 from 'react';
12
+ import { PropsWithChildren, Dispatch, SetStateAction, RefObject } from 'react';
13
+ import * as react_jsx_runtime from 'react/jsx-runtime';
14
+
15
+ interface CreateCartInput {
16
+ /** Lines to add to the cart */
17
+ lines?: CartLineInput[];
18
+ /** Buyer identity for cart creation */
19
+ buyerIdentity?: {
20
+ email?: string;
21
+ countryCode?: string;
22
+ };
23
+ /** Discount codes */
24
+ discountCodes?: string[];
25
+ /** Custom attributes */
26
+ customAttributes?: Array<{
27
+ key: string;
28
+ value: string;
29
+ }>;
30
+ }
31
+ /**
32
+ * Hook for creating a new cart
33
+ *
34
+ * Automatically removes invalid discount codes after creating cart
35
+ *
36
+ * @param options - SWR mutation configuration
37
+ * @returns SWR mutation with trigger function
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * const { trigger, isMutating } = useCreateCart()
42
+ *
43
+ * // Create empty cart
44
+ * await trigger({})
45
+ *
46
+ * // Create cart with items
47
+ * await trigger({
48
+ * lines: [{
49
+ * merchandiseId: 'gid://shopify/ProductVariant/123',
50
+ * quantity: 1
51
+ * }],
52
+ * buyerIdentity: {
53
+ * email: 'customer@example.com',
54
+ * countryCode: 'US'
55
+ * },
56
+ * discountCodes: ['SUMMER2024']
57
+ * })
58
+ * ```
59
+ */
60
+ declare function useCreateCart(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'create-cart', CreateCartInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "create-cart", CreateCartInput>;
61
+
62
+ interface AddCartLinesInput {
63
+ /** Cart ID (optional, will use cookie or create new cart) */
64
+ cartId?: string;
65
+ /** Lines to add */
66
+ lines: CartLineInput[];
67
+ /** Buyer identity for new cart */
68
+ buyerIdentity?: {
69
+ email?: string;
70
+ countryCode?: string;
71
+ };
72
+ }
73
+ /**
74
+ * Hook for adding lines to cart
75
+ *
76
+ * Automatically removes invalid discount codes after adding items
77
+ *
78
+ * @param options - SWR mutation configuration
79
+ * @returns SWR mutation with trigger function
80
+ *
81
+ * @example
82
+ * ```tsx
83
+ * const { trigger, isMutating } = useAddCartLines()
84
+ *
85
+ * await trigger({
86
+ * lines: [{
87
+ * merchandiseId: 'gid://shopify/ProductVariant/123',
88
+ * quantity: 1
89
+ * }]
90
+ * })
91
+ * ```
92
+ */
93
+ declare function useAddCartLines(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'add-cart-lines', AddCartLinesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "add-cart-lines", AddCartLinesInput>;
94
+
95
+ /**
96
+ * Hook for updating cart line quantities
97
+ *
98
+ * @param options - SWR mutation configuration
99
+ * @returns SWR mutation with trigger function
100
+ *
101
+ * @example
102
+ * ```tsx
103
+ * const { trigger, isMutating } = useUpdateCartLines()
104
+ *
105
+ * await trigger({
106
+ * lines: [{
107
+ * id: 'gid://shopify/CartLine/123',
108
+ * quantity: 2
109
+ * }]
110
+ * })
111
+ * ```
112
+ */
113
+ declare function useUpdateCartLines(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-cart-lines', UpdateCartLinesOptions>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-lines", UpdateCartLinesOptions>;
114
+
115
+ interface RemoveCartLinesInput {
116
+ /** Cart ID (optional, will use cookie) */
117
+ cartId?: string;
118
+ /** Line IDs to remove */
119
+ lineIds: string[];
120
+ /** Whether to automatically remove invalid discount codes (default: true) */
121
+ autoRemoveInvalidCodes?: boolean;
122
+ /** Callback when discount codes are removed */
123
+ onCodesRemoved?: (updatedCart: NormalizedCart, removedCodes: string[]) => Promise<NormalizedCart | undefined>;
124
+ }
125
+ /**
126
+ * Hook for removing lines from cart
127
+ *
128
+ * Automatically removes invalid discount codes after removing items
129
+ *
130
+ * @param options - SWR mutation configuration
131
+ * @returns SWR mutation with trigger function
132
+ *
133
+ * @example
134
+ * ```tsx
135
+ * const { trigger, isMutating } = useRemoveCartLines()
136
+ *
137
+ * await trigger({
138
+ * lineIds: ['gid://shopify/CartLine/123']
139
+ * })
140
+ * ```
141
+ */
142
+ declare function useRemoveCartLines(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'remove-cart-lines', RemoveCartLinesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "remove-cart-lines", RemoveCartLinesInput>;
143
+
144
+ interface ApplyCartCodesInput {
145
+ /** Cart ID (required) */
146
+ cartId?: string;
147
+ /** Discount codes to apply (added to existing applicable codes) */
148
+ discountCodes: string[];
149
+ /** Replace existing applicable codes */
150
+ replaceExistingCodes?: boolean;
151
+ }
152
+ /**
153
+ * Hook for applying discount codes to cart
154
+ *
155
+ * Merges new codes with existing applicable codes and validates them
156
+ *
157
+ * @param options - SWR mutation configuration
158
+ * @returns SWR mutation with trigger function
159
+ *
160
+ * @example
161
+ * ```tsx
162
+ * const { trigger, isMutating, error } = useApplyCartCodes()
163
+ *
164
+ * try {
165
+ * await trigger({
166
+ * cartId: 'gid://shopify/Cart/123',
167
+ * discountCodes: ['SUMMER2024']
168
+ * })
169
+ * } catch (error) {
170
+ * // Handle unapplicable codes
171
+ * }
172
+ * ```
173
+ */
174
+ declare function useApplyCartCodes(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'apply-codes', ApplyCartCodesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "apply-codes", ApplyCartCodesInput>;
175
+
176
+ interface RemoveCartCodesInput {
177
+ /** Cart ID (required) */
178
+ cartId?: string;
179
+ /** Discount codes to remove */
180
+ discountCodes: string[];
181
+ }
182
+ /**
183
+ * Hook for removing discount codes from cart
184
+ *
185
+ * @param options - SWR mutation configuration
186
+ * @returns SWR mutation with trigger function
187
+ *
188
+ * @example
189
+ * ```tsx
190
+ * const { trigger, isMutating } = useRemoveCartCodes()
191
+ *
192
+ * await trigger({
193
+ * cartId: 'gid://shopify/Cart/123',
194
+ * discountCodes: ['EXPIRED_CODE']
195
+ * })
196
+ * ```
197
+ */
198
+ declare function useRemoveCartCodes(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'remove-codes', RemoveCartCodesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "remove-codes", RemoveCartCodesInput>;
199
+
200
+ interface UpdateCartAttributesInput {
201
+ /** Cart ID (optional, will use cookie) */
202
+ cartId?: string;
203
+ /** Custom attributes to set on cart */
204
+ attributes: Array<{
205
+ key: string;
206
+ value: string;
207
+ }>;
208
+ }
209
+ /**
210
+ * Hook for updating cart attributes (custom key-value pairs)
211
+ *
212
+ * @param options - SWR mutation configuration
213
+ * @returns SWR mutation with trigger function
214
+ *
215
+ * @example
216
+ * ```tsx
217
+ * const { trigger, isMutating } = useUpdateCartAttributes()
218
+ *
219
+ * await trigger({
220
+ * attributes: [
221
+ * { key: 'gift_message', value: 'Happy Birthday!' },
222
+ * { key: 'gift_wrap', value: 'true' }
223
+ * ]
224
+ * })
225
+ * ```
226
+ */
227
+ declare function useUpdateCartAttributes(mutate: (cart: NormalizedCart | undefined) => void, metafieldIdentifiers?: {
228
+ variant: HasMetafieldsIdentifier[];
229
+ product: HasMetafieldsIdentifier[];
230
+ }, options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-cart-attributes', UpdateCartAttributesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
231
+
232
+ interface BuyNowInput {
233
+ /** Metafield identifiers */
234
+ metafieldIdentifiers?: {
235
+ variant: HasMetafieldsIdentifier[];
236
+ product: HasMetafieldsIdentifier[];
237
+ };
238
+ /** Line items to add to the new cart */
239
+ lineItems: Array<AddToCartLineItem>;
240
+ /** Discount codes to apply */
241
+ discountCodes?: string[];
242
+ /** Custom attributes for the cart */
243
+ customAttributes?: Array<{
244
+ key: string;
245
+ value: string;
246
+ }>;
247
+ /** Buyer identity */
248
+ buyerIdentity?: {
249
+ email?: string;
250
+ countryCode?: string;
251
+ };
252
+ /** GTM tracking parameters */
253
+ gtmParams?: Omit<GtmParams, 'brand'>;
254
+ /** Facebook Pixel tracking configuration */
255
+ fbqTrackConfig?: BuyNowTrackConfig;
256
+ /** Whether to redirect to checkout page (default: true) */
257
+ redirectToCheckout?: boolean;
258
+ }
259
+ interface UseBuyNowOptions {
260
+ /** Enable tracking (GA and FBQ) */
261
+ withTrack?: boolean;
262
+ }
263
+ /**
264
+ * Hook for buy now functionality
265
+ *
266
+ * Creates a new cart with the specified items and redirects to checkout.
267
+ * Includes automatic tracking for GA4 and Facebook Pixel.
268
+ *
269
+ * @param options - Hook configuration
270
+ * @param swrOptions - SWR mutation configuration
271
+ * @returns SWR mutation with trigger function
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * const { trigger, isMutating } = useBuyNow({
276
+ * withTrack: true,
277
+ * redirectToCheckout: true,
278
+ * })
279
+ *
280
+ * await trigger({
281
+ * lineItems: [{
282
+ * variantId: 'gid://shopify/ProductVariant/123',
283
+ * quantity: 1
284
+ * }],
285
+ * gtmParams: {
286
+ * pageGroup: 'PDP',
287
+ * position: 'Buy Now Button'
288
+ * }
289
+ * })
290
+ * ```
291
+ */
292
+ declare function useBuyNow({ withTrack }?: UseBuyNowOptions, swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, string, BuyNowInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, string, BuyNowInput>;
293
+
294
+ type AutoFreeGift = {
295
+ currentTier: {
296
+ amount: number;
297
+ gift?: NormalizedProductVariant;
298
+ };
299
+ nextTierGoal: {
300
+ amount: number;
301
+ gift?: NormalizedProductVariant;
302
+ };
303
+ };
304
+ type DiscountLabel = {
305
+ cart_checkout_label: string;
306
+ product_label: string;
307
+ sold_out_label: string;
308
+ };
309
+ type AutoFreeGiftMainProduct = {
310
+ spend_money_type: number;
311
+ variant_id_list: string[];
312
+ all_store_variant: boolean;
313
+ };
314
+ type GiftProduct = {
315
+ spend_sum_money: number;
316
+ gift_type: number;
317
+ reward_list: {
318
+ get_unit: number;
319
+ variant_id: string;
320
+ bak_variant_id_list: null;
321
+ }[];
322
+ };
323
+ type AutoFreeGiftConfig = Config[];
324
+ type RuleCondition = {
325
+ with_special_url_params: string[];
326
+ without_special_url_params: string[];
327
+ with_user_tags: string[];
328
+ without_user_tags: string[];
329
+ };
330
+ type MainProductInfo = {
331
+ spend_money_type: SpendMoneyType;
332
+ variant_list: VariantItem[];
333
+ all_store_variant: boolean;
334
+ };
335
+ type Config = {
336
+ rule_id: number;
337
+ rule_type: RuleType;
338
+ discount_label: {
339
+ cart_checkout_label: string;
340
+ product_label: string;
341
+ sold_out_label: string;
342
+ };
343
+ frontend_labels: {
344
+ key: string;
345
+ label: string;
346
+ desc: string;
347
+ }[];
348
+ apply_unit: number;
349
+ rule_result: {
350
+ buy_rule_type: BuyRuleType;
351
+ spend_get_reward: {
352
+ main_product: MainProductInfo;
353
+ gift_product: GiftProductItem[];
354
+ };
355
+ buy_get_reward: {
356
+ main_product: MainProductInfo;
357
+ gift_product: GiftProductItem[] | null;
358
+ };
359
+ };
360
+ rule_conditions?: RuleCondition[];
361
+ };
362
+ interface GiftTier {
363
+ spend_sum_money: number;
364
+ gift_type: number;
365
+ reward_list: RewardItem[];
366
+ }
367
+ interface RewardItem {
368
+ get_unit: number;
369
+ variant_list: VariantItem[];
370
+ }
371
+ interface VariantItem {
372
+ variant_id: string;
373
+ sku: string;
374
+ handle: string;
375
+ discount_value: number;
376
+ }
377
+ interface GiftProductItem {
378
+ spend_sum_money: number;
379
+ gift_type: number;
380
+ reward_list: RewardItem[];
381
+ }
382
+ declare enum RuleType {
383
+ AUTO_FREE_GIFT = 1,// 自动赠品
384
+ BUNDLE = 2,// 组合
385
+ VOLUME_DISCOUNT = 3,// 量价折扣
386
+ ORDER_DISCOUNT = 4,// 订单折扣
387
+ PRICE_DISCOUNT = 5
388
+ }
389
+ declare enum BuyRuleType {
390
+ BUY_GET_GIFT = 1,// 买赠
391
+ SPEND_GET_GIFT = 2
392
+ }
393
+ declare enum SpendMoneyType {
394
+ ORIGIN_PRICE = 1,// 原价
395
+ DISCOUNT_PRICE = 2
396
+ }
397
+ interface FunctionGiftResult {
398
+ qualifyingGift: FormattedGift | null;
399
+ nextTierGoal: GiftTier | null;
400
+ activeCampaign: Config | null;
401
+ isLoading: boolean;
402
+ giftProductsResult?: NormalizedProduct[] | [];
403
+ }
404
+ interface FormattedGift {
405
+ tier: GiftTier;
406
+ itemsToAdd: AutoFreeGiftCartLineInput[];
407
+ }
408
+ interface AutoFreeGiftCartLineInput {
409
+ variant: {
410
+ id: string;
411
+ handle: string;
412
+ sku: string;
413
+ };
414
+ quantity: number;
415
+ attributes: {
416
+ key: string;
417
+ value: string;
418
+ }[];
419
+ }
420
+ type AutoFreeGiftItem = {
421
+ line: NormalizedLineItem;
422
+ isSoldOut: boolean;
423
+ };
424
+ type AutoFreeGiftList = AutoFreeGiftItem[] | [];
425
+
426
+ /**
427
+ * [计算型 Hook]
428
+ * 根据购物车、活动配置和用户信息,计算出应得的赠品和下一个目标。
429
+ * 此 Hook 不产生任何副作用。
430
+ * 使用示例:
431
+ * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig);
432
+ *
433
+ * 也可以传入 lines 参数来计算加购前的赠品:
434
+ * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig, customer, lines);
435
+ */
436
+ declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
437
+
438
+ interface GiveawayProduct {
439
+ handle: string;
440
+ sku: string;
441
+ }
442
+ interface Breakpoint {
443
+ breakpoint: string;
444
+ giveawayProducts: GiveawayProduct[];
445
+ }
446
+ interface Campaign {
447
+ activityAvailableQuery?: string;
448
+ activityQroperty?: string;
449
+ breakpoints?: Array<{
450
+ breakpoint: string;
451
+ giveawayProducts: GiveawayProduct[];
452
+ }>;
453
+ includeTags?: string[];
454
+ useTotalAmount?: boolean;
455
+ }
456
+ interface UseScriptAutoFreeGiftResult {
457
+ involvedLines: NormalizedLineItem[];
458
+ reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
459
+ disableCodeRemove: boolean;
460
+ nextFreeGiftLevel: Breakpoint | null;
461
+ freeGiftLevel: Breakpoint | null;
462
+ involvedSubTotal: Decimal;
463
+ giftProductsResult?: NormalizedProduct[];
464
+ }
465
+ declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, }: {
466
+ campaign: Campaign | null;
467
+ _giveaway: string;
468
+ cart: NormalizedCart | undefined;
469
+ locale?: string;
470
+ lines?: AddToCartLineItem[];
471
+ }) => UseScriptAutoFreeGiftResult;
472
+
473
+ interface UseCalcGiftsFromLinesOptions {
474
+ /** Lines to calculate gifts from (AddToCartLineItem format) */
475
+ lines: AddToCartLineItem[];
476
+ /** Auto free gift configuration (Function gift) */
477
+ autoFreeGiftConfig?: AutoFreeGiftConfig;
478
+ /** Customer information (required for function gift) */
479
+ customer?: any;
480
+ /** Script gift campaign configuration */
481
+ scriptCampaign?: any;
482
+ /** Script giveaway attribute key */
483
+ scriptGiveawayKey?: string;
484
+ /** Locale for product fetching (optional, will use from ShopifyProvider if not provided) */
485
+ locale?: string;
486
+ }
487
+ interface UseCalcGiftsFromLinesResult {
488
+ /** Function gift calculation result */
489
+ functionGift: FunctionGiftResult;
490
+ /** Script gift calculation result */
491
+ scriptGift: UseScriptAutoFreeGiftResult;
492
+ /** All gift lines that need to be added to cart (combined from both) */
493
+ allGiftLines: AutoFreeGiftCartLineInput[];
494
+ /** Whether any gifts are available */
495
+ hasGifts: boolean;
496
+ }
497
+ /**
498
+ * Calculate gifts from AddToCartLineItem[] before adding to cart
499
+ * Supports both function-based gifts (useCalcAutoFreeGift) and script-based gifts (useScriptAutoFreeGift)
500
+ *
501
+ * Automatically uses locale from ShopifyProvider and cart from CartContext if not provided.
502
+ *
503
+ * @example
504
+ * ```tsx
505
+ * // Basic usage (locale from context, customer required for function gift)
506
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
507
+ * lines: [{ variant: myVariant, quantity: 2 }],
508
+ * customer: currentCustomer,
509
+ * autoFreeGiftConfig: functionGiftConfig,
510
+ * scriptCampaign: scriptGiftConfig,
511
+ * })
512
+ *
513
+ * // Script gift only (no customer needed)
514
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
515
+ * lines: [{ variant: myVariant, quantity: 2 }],
516
+ * scriptCampaign: scriptGiftConfig,
517
+ * })
518
+ *
519
+ * // With custom locale
520
+ * const { allGiftLines, hasGifts } = useCalcGiftsFromLines({
521
+ * lines: [{ variant: myVariant, quantity: 2 }],
522
+ * customer: currentCustomer,
523
+ * locale: 'fr',
524
+ * autoFreeGiftConfig: functionGiftConfig,
525
+ * })
526
+ *
527
+ * // Then add both products and gifts to cart
528
+ * await addToCart({
529
+ * lineItems: [...lines, ...allGiftLines]
530
+ * })
531
+ * ```
532
+ */
533
+ declare function useCalcGiftsFromLines({ lines, customer, scriptGiveawayKey, }: UseCalcGiftsFromLinesOptions): UseCalcGiftsFromLinesResult;
534
+
535
+ declare enum OrderDiscountType {
536
+ PERCENTAGE = 1,// 百分比折扣
537
+ FIXED_AMOUNT = 2,// 固定金额折扣
538
+ REDUCE_PRICE = 3
539
+ }
540
+ declare enum OrderBasePriceType {
541
+ ORIGIN_PRICE = 1,// 原价
542
+ MIN_DISCOUNTED_PRICE = 2
543
+ }
544
+ type TieredDiscount = {
545
+ amount: number;
546
+ discount: number;
547
+ discount_type: OrderDiscountType;
548
+ };
549
+ type OrderDiscountConfig = {
550
+ rule_id: number;
551
+ rule_type: number;
552
+ rule_conditions?: RuleCondition[];
553
+ result_detail: {
554
+ main_product: {
555
+ variant_list: Array<{
556
+ variant_id: string;
557
+ sku: string;
558
+ handle: string;
559
+ }>;
560
+ all_store_variant: boolean;
561
+ skip_variants?: Array<{
562
+ variant_id: string;
563
+ sku: string;
564
+ handle: string;
565
+ }>;
566
+ };
567
+ order_discount_conf: {
568
+ base_price: OrderBasePriceType;
569
+ tiered_discounts: TieredDiscount[];
570
+ tiered_discounts_markets?: Record<string, TieredDiscount[]>;
571
+ is_reusable?: boolean;
572
+ min_quantity_items?: number;
573
+ max_apply_times_of_per_order?: number;
574
+ };
575
+ };
576
+ discount_label?: {
577
+ cart_checkout_label?: string;
578
+ product_label?: string;
579
+ sold_out_label?: string;
580
+ };
581
+ frontend_labels?: any[];
582
+ discount_combinations?: {
583
+ other_order_discounts?: boolean;
584
+ other_product_discounts?: boolean;
585
+ shipping_discounts?: boolean;
586
+ };
587
+ };
588
+
589
+ interface OrderDiscountResult {
590
+ qualifyingDiscount: TieredDiscount | null;
591
+ nextTierGoal: TieredDiscount | null;
592
+ activeCampaign: OrderDiscountConfig | null;
593
+ discountAmount: number;
594
+ cartTotalForDiscount: number;
595
+ isLoading: boolean;
596
+ }
597
+ /**
598
+ * [计算型 Hook]
599
+ * 根据购物车、活动配置和用户信息,计算出应得的订单折扣和下一个目标。
600
+ * 此 Hook 不产生任何副作用。
601
+ * 使用示例:
602
+ * const { qualifyingDiscount, nextTierGoal, activeCampaign, discountAmount, isLoading } = useCalcOrderDiscount(cart, orderDiscountConfig);
603
+ * @param cart - 购物车
604
+ * @param orderDiscountConfig - 订单折扣配置
605
+ * @returns { OrderDiscountResult }
606
+ */
607
+ declare const useCalcOrderDiscount: (cart: any, orderDiscountConfig: OrderDiscountConfig[], customer: any) => OrderDiscountResult;
608
+
609
+ interface ShippingMethodsContext {
610
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
611
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
612
+ nddOverweight: boolean;
613
+ tddOverweight: boolean;
614
+ }
615
+ interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile = any> {
616
+ plusMemberMetafields: PlusMemberSettingsMetafields;
617
+ shopCommon?: Record<string, any>;
618
+ zipCode: string;
619
+ setZipCode: (value: string) => void;
620
+ allowNextDayDelivery: boolean;
621
+ setAllowNextDayDelivery: (value: boolean) => void;
622
+ allowThirdDayDelivery: boolean;
623
+ setAllowThirdDayDelivery: (value: boolean) => void;
624
+ selectedPlusMemberMode: DeliveryPlusType;
625
+ setSelectedPlusMemberMode: (value: DeliveryPlusType) => void;
626
+ showAreaCheckModal: boolean;
627
+ setShowAreaCheckModal: (value: boolean) => void;
628
+ selectedShippingMethod?: PlusMemberShippingMethodConfig;
629
+ setSelectedShippingMethod: (value: PlusMemberShippingMethodConfig) => void;
630
+ showTip: boolean;
631
+ setShowTip: (value: boolean) => void;
632
+ showMoreShippingMethod: boolean;
633
+ setShowMoreShippingMethod: (value: boolean) => void;
634
+ variant: TVariant;
635
+ product: TProduct;
636
+ shippingMethodsContext: ShippingMethodsContext;
637
+ selectedPlusMemberProduct: SelectedPlusMemberProduct;
638
+ plusMemberProducts: NormalizedProduct[];
639
+ showPlusMemberBenefit: boolean;
640
+ setShowPlusMemberBenefit: (value: boolean) => void;
641
+ deleteMarginBottom: boolean;
642
+ setDeleteMarginBottom: (value: boolean) => void;
643
+ profile?: TProfile;
644
+ locale?: string;
645
+ }
646
+ declare const PlusMemberContext: React$1.Context<PlusMemberContextValue<any, any, any>>;
647
+
648
+ /**
649
+ * Hook to access Plus Member Context
650
+ */
651
+ declare function usePlusMemberContext<TProduct = any, TVariant = any>(): PlusMemberContextValue<any, any, any>;
652
+
653
+ /**
654
+ * Hook to get Plus Monthly Product Variant
655
+ */
656
+ declare function usePlusMonthlyProductVariant<TVariant = any>(): TVariant | undefined;
657
+
658
+ /**
659
+ * Hook to get Plus Annual Product Variant
660
+ */
661
+ declare function usePlusAnnualProductVariant<TVariant = any>(): TVariant | undefined;
662
+
663
+ /**
664
+ * Hook to calculate available shipping methods based on product weight and member status
665
+ */
666
+
667
+ interface UseShippingMethodsOptions<TVariant = any> {
668
+ /** Product variant with weight information */
669
+ variant: TVariant;
670
+ /** Zip code for delivery */
671
+ zipCode: string;
672
+ /** Whether next day delivery is allowed */
673
+ allowNextDayDelivery: boolean;
674
+ /** Whether third day delivery is allowed */
675
+ allowThirdDayDelivery: boolean;
676
+ /** Plus member metafields configuration */
677
+ plusMemberMetafields: PlusMemberSettingsMetafields;
678
+ /** Selected plus member mode */
679
+ selectedPlusMemberMode: DeliveryPlusType;
680
+ /** Whether user is a plus member */
681
+ isPlus?: boolean;
682
+ /** Available NDD coupon code */
683
+ nddCoupon?: string;
684
+ /** Available TDD coupon code */
685
+ tddCoupon?: string;
686
+ }
687
+ interface UseShippingMethodsResult {
688
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
689
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
690
+ nddOverweight: boolean;
691
+ tddOverweight: boolean;
692
+ }
693
+ /**
694
+ * Calculate available shipping methods based on product weight, member status, and available coupons
695
+ *
696
+ * @param options - Configuration options
697
+ * @returns Shipping methods categorized by free/payment and overweight status
698
+ *
699
+ * @example
700
+ * ```tsx
701
+ * const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
702
+ * variant,
703
+ * zipCode,
704
+ * allowNextDayDelivery,
705
+ * allowThirdDayDelivery,
706
+ * plusMemberMetafields,
707
+ * selectedPlusMemberMode,
708
+ * isPlus: profile?.isPlus,
709
+ * nddCoupon,
710
+ * tddCoupon,
711
+ * })
712
+ * ```
713
+ */
714
+ declare function useShippingMethods<TVariant extends {
715
+ weight?: number;
716
+ } = any>(options: UseShippingMethodsOptions<TVariant>): UseShippingMethodsResult;
717
+
718
+ /**
719
+ * Hook to check shipping method availability and automatically adjust selection
720
+ */
721
+ declare function useShippingMethodAvailableCheck(): void;
722
+
723
+ /**
724
+ * Hook to replace cart plus member product
725
+ *
726
+ * When adding a monthly membership while an annual membership exists in cart,
727
+ * the annual membership will be replaced and vice versa.
728
+ *
729
+ * @returns Handler function to replace conflicting membership products
730
+ *
731
+ * @example
732
+ * ```tsx
733
+ * const replaceCartPlusMember = useReplaceCartPlusMember()
734
+ *
735
+ * // Call before adding new membership product
736
+ * await replaceCartPlusMember()
737
+ * ```
738
+ */
739
+ declare const useReplaceCartPlusMember: () => () => Promise<void>;
740
+
741
+ /**
742
+ * Hook to get delivery discount codes from delivery data
743
+ *
744
+ * Extracts and returns the discount codes from the delivery custom data.
745
+ *
746
+ * @param deliveryData - Delivery data containing custom attributes
747
+ * @returns Array of discount codes or undefined
748
+ *
749
+ * @example
750
+ * ```tsx
751
+ * const deliveryCodes = usePlusMemberDeliveryCodes({ deliveryData })
752
+ * ```
753
+ */
754
+ declare const usePlusMemberDeliveryCodes: ({ deliveryData, }: {
755
+ deliveryData?: DeliveryData;
756
+ }) => string[] | undefined;
757
+
758
+ interface UseUpdatePlusMemberDeliveryOptionsProps {
759
+ /** SWR mutation configuration */
760
+ options?: SWRMutationConfiguration<any, Error, 'update-cart-delivery-options', {
761
+ deliveryData: DeliveryData;
762
+ }>;
763
+ }
764
+ /**
765
+ * Hook to update cart delivery options based on plus member delivery data
766
+ *
767
+ * This hook extracts the selected delivery option from delivery custom data and
768
+ * maps it to the appropriate delivery option handle from the cart's deliveryGroups.
769
+ * It then triggers the update-cart-delivery-options mutation to apply the selection.
770
+ *
771
+ * The hook handles:
772
+ * - Extracting delivery option code from deliveryCustomData.selected_delivery_option
773
+ * - Finding the matching delivery option in cart.deliveryGroups
774
+ * - Triggering the cart update with the correct delivery option handle
775
+ *
776
+ * @param props - Hook properties
777
+ * @returns useSWRMutation result with trigger and loading state
778
+ *
779
+ * @example
780
+ * ```tsx
781
+ * const { trigger, isMutating } = useUpdatePlusMemberDeliveryOptions()
782
+ *
783
+ * // Trigger update with delivery data
784
+ * await trigger({ deliveryData })
785
+ * ```
786
+ */
787
+ declare const useUpdatePlusMemberDeliveryOptions: ({ options, }?: UseUpdatePlusMemberDeliveryOptionsProps) => swr_mutation.SWRMutationResponse<any, Error, "update-cart-delivery-options", {
788
+ deliveryData: DeliveryData;
789
+ }>;
790
+
791
+ /**
792
+ * Hook to generate custom attributes for cart line items
793
+ *
794
+ * Creates custom attributes based on delivery data to be attached to line items.
795
+ *
796
+ * @param deliveryData - Delivery data containing custom attributes
797
+ * @returns Array of custom attributes for line items
798
+ *
799
+ * @example
800
+ * ```tsx
801
+ * const itemAttributes = usePlusMemberItemCustomAttributes({ deliveryData })
802
+ *
803
+ * // Use in addToCart
804
+ * await addToCart({
805
+ * lineItems: lineItems.map(item => ({
806
+ * ...item,
807
+ * customAttributes: [...(item.customAttributes || []), ...itemAttributes]
808
+ * }))
809
+ * })
810
+ * ```
811
+ */
812
+ declare const usePlusMemberItemCustomAttributes: ({ deliveryData, }: {
813
+ deliveryData?: DeliveryData;
814
+ }) => NormalizedAttribute[];
815
+
816
+ /**
817
+ * Hook to generate custom attributes for checkout
818
+ *
819
+ * Creates custom attributes based on delivery data, profile, and customer information
820
+ * to be attached to the checkout.
821
+ *
822
+ * Requires profile to be provided via PlusMemberContext.
823
+ *
824
+ * @param deliveryData - Delivery data containing custom attributes
825
+ * @param product - Product information (optional, for hiding shipping benefits check)
826
+ * @param variant - Variant information (optional, for presale and hiding shipping benefits check)
827
+ * @param isShowShippingBenefits - Function to check if shipping benefits should be shown (optional)
828
+ * @returns Array of custom attributes for checkout
829
+ *
830
+ * @example
831
+ * ```tsx
832
+ * const checkoutAttributes = usePlusMemberCheckoutCustomAttributes({
833
+ * deliveryData,
834
+ * product,
835
+ * variant,
836
+ * customer,
837
+ * isShowShippingBenefits
838
+ * })
839
+ *
840
+ * // Use in checkout
841
+ * await createCheckout({
842
+ * lineItems,
843
+ * customAttributes: checkoutAttributes
844
+ * })
845
+ * ```
846
+ */
847
+ declare const usePlusMemberCheckoutCustomAttributes: <TProduct = any, TVariant = any>({ deliveryData, product, variant, isShowShippingBenefits, }: {
848
+ deliveryData?: DeliveryData;
849
+ product?: TProduct;
850
+ variant?: TVariant;
851
+ isShowShippingBenefits?: (args: {
852
+ variant?: TVariant;
853
+ product?: TProduct;
854
+ setting: any;
855
+ }) => boolean;
856
+ }) => NormalizedAttribute[];
857
+
858
+ /**
859
+ * useAutoRemovePlusMemberInCart Hook
860
+ * 付费会员身份自动移除购物车中的会员产品
861
+ * 年费会员删除月费会员产品,月费会员删除年费会员产品
862
+ */
863
+
864
+ interface UseAutoRemovePlusMemberInCartProps {
865
+ profile: any;
866
+ cart?: NormalizedCart;
867
+ memberSetting: PlusMemberSettingsMetafields;
868
+ }
869
+ /**
870
+ * 自动移除购物车中的会员产品
871
+ *
872
+ * @param props - Hook 参数
873
+ * @param props.memberSetting - Plus Member 配置
874
+ * @param props.isMonthlyPlus - 用户是否是月费会员
875
+ * @param props.isAnnualPlus - 用户是否是年费会员
876
+ *
877
+ * @example
878
+ * ```tsx
879
+ * const { profile } = useProfile()
880
+ *
881
+ * useAutoRemovePlusMemberInCart({
882
+ * cart,
883
+ * profile,
884
+ * })
885
+ * ```
886
+ */
887
+ declare function useAutoRemovePlusMemberInCart({ cart, profile, memberSetting, }: UseAutoRemovePlusMemberInCartProps): void;
888
+
889
+ /**
890
+ * useHasPlusMemberInCart Hook
891
+ * 判断购物车中是否包含年费会员或月费会员产品
892
+ */
893
+
894
+ interface UseHasPlusMemberInCartProps {
895
+ /** Plus Member 配置 */
896
+ memberSetting?: PlusMemberSettingsMetafields;
897
+ /** 购物车数据 */
898
+ cart?: NormalizedCart;
899
+ }
900
+ interface HasPlusMemberInCartResult {
901
+ /** 购物车中是否有任何会员产品 */
902
+ hasPlusMember: boolean;
903
+ /** 购物车中是否有月费会员产品 */
904
+ hasMonthlyPlus: boolean;
905
+ /** 购物车中是否有年费会员产品 */
906
+ hasAnnualPlus: boolean;
907
+ /** 月费会员产品的 line item */
908
+ monthlyPlusItem?: {
909
+ id: string;
910
+ quantity: number;
911
+ handle?: string;
912
+ sku?: string;
913
+ };
914
+ /** 年费会员产品的 line item */
915
+ annualPlusItem?: {
916
+ id: string;
917
+ quantity: number;
918
+ handle?: string;
919
+ sku?: string;
920
+ };
921
+ }
922
+ /**
923
+ * 判断购物车中是否包含年费会员或月费会员产品
924
+ *
925
+ * @param props - Hook 参数
926
+ * @param props.metafields - Plus Member 配置
927
+ * @returns 会员产品信息
928
+ *
929
+ * @example
930
+ * ```tsx
931
+ * const {
932
+ * hasPlusMember,
933
+ * hasMonthlyPlus,
934
+ * hasAnnualPlus,
935
+ * monthlyPlusItem,
936
+ * annualPlusItem,
937
+ * } = useHasPlusMemberInCart({
938
+ * memberSetting: plusMemberSettings,
939
+ * })
940
+ *
941
+ * if (hasPlusMember) {
942
+ * console.log('购物车中有会员产品')
943
+ * }
944
+ * ```
945
+ */
946
+ declare function useHasPlusMemberInCart({ memberSetting, cart, }: UseHasPlusMemberInCartProps): HasPlusMemberInCartResult;
947
+
948
+ /**
949
+ * 返回需要添加到购物车的 Plus Member 产品
950
+ *
951
+ * 该 hook 会根据用户选择的会员模式和购物车现有状态,
952
+ * 返回需要添加的会员产品。如果不需要添加会员产品,则返回 undefined。
953
+ *
954
+ * @param props - Hook 参数
955
+ * @param props.cart - 购物车数据
956
+ * @returns Plus Member 产品对象或 undefined
957
+ *
958
+ * @example
959
+ * ```tsx
960
+ * const plusMemberProduct = useAddPlusMemberProductsToCart({
961
+ * cart,
962
+ * })
963
+ *
964
+ * // plusMemberProduct 格式:
965
+ * // {
966
+ * // product: NormalizedProduct,
967
+ * // variant: NormalizedProductVariant
968
+ * // }
969
+ * // 或 undefined (当不需要添加会员产品时)
970
+ * ```
971
+ */
972
+ declare function useAddPlusMemberProductsToCart({ cart, profile, }: {
973
+ cart: NormalizedCart;
974
+ profile?: any;
975
+ }): {
976
+ product: _anker_in_shopify_sdk.NormalizedProduct;
977
+ variant: _anker_in_shopify_sdk.NormalizedProductVariant;
978
+ } | undefined;
979
+
980
+ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
981
+ variant: TVariant;
982
+ product: TProduct;
983
+ memberSetting: PlusMemberSettingsMetafields;
984
+ initialSelectedPlusMemberMode?: DeliveryPlusType;
985
+ profile?: TProfile;
986
+ locale?: string;
987
+ }
988
+ /**
989
+ * Plus Member Provider Component
990
+ *
991
+ * Provides Plus Member context and state management to child components.
992
+ *
993
+ * @param variant - Product variant
994
+ * @param product - Product
995
+ * @param metafields - Plus member settings from metafields
996
+ * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
997
+ * @param profile - User profile
998
+ * @param locale - Locale code
999
+ * @param children - Child components
1000
+ *
1001
+ * @example
1002
+ * ```tsx
1003
+ * <PlusMemberProvider
1004
+ * variant={variant}
1005
+ * product={product}
1006
+ * memberSetting={memberSetting}
1007
+ * profile={profile}
1008
+ * locale={locale}
1009
+ * >
1010
+ * <YourComponent />
1011
+ * </PlusMemberProvider>
1012
+ * ```
1013
+ */
1014
+ declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, locale, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
1015
+
1016
+ declare const getReferralAttributes: () => {
1017
+ key: string;
1018
+ value: any;
1019
+ }[];
1020
+ declare const useCartAttributes: ({ profile, customer, cart, memberSetting, }: {
1021
+ profile: any;
1022
+ customer: any;
1023
+ cart?: NormalizedCart;
1024
+ memberSetting?: PlusMemberSettingsMetafields;
1025
+ }) => {
1026
+ attributes: Array<{
1027
+ key: string;
1028
+ value: any;
1029
+ }>;
1030
+ };
1031
+
1032
+ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
1033
+ cart?: NormalizedCart;
1034
+ cartItem: NormalizedLineItem;
1035
+ config: {
1036
+ handle: Record<string, {
1037
+ min: number;
1038
+ max: number;
1039
+ }>;
1040
+ sku: Record<string, {
1041
+ min: number;
1042
+ max: number;
1043
+ }>;
1044
+ };
1045
+ }) => {
1046
+ min: number;
1047
+ max: number;
1048
+ };
1049
+
1050
+ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
1051
+ cart?: NormalizedCart;
1052
+ mutateCart: (cart: NormalizedCart | undefined) => void;
1053
+ isCartLoading: boolean;
1054
+ setLoadingState: React.Dispatch<React.SetStateAction<any>>;
1055
+ metafieldIdentifiers?: {
1056
+ variant: HasMetafieldsIdentifier[];
1057
+ product: HasMetafieldsIdentifier[];
1058
+ };
1059
+ }) => void;
1060
+
1061
+ declare enum PriceDiscountType {
1062
+ PERCENTAGE = 1,// 百分比折扣
1063
+ FIXED_AMOUNT = 2
1064
+ }
1065
+ declare enum PriceBasePriceType {
1066
+ MIN_DISCOUNTED_PRICE = 1,// 最低折扣价
1067
+ MIN_TOTAL_PRICE = 2
1068
+ }
1069
+ type PriceDiscountConfig = {
1070
+ rule_id: number;
1071
+ rule_type: number;
1072
+ discount_type: PriceDiscountType;
1073
+ discount_value: number;
1074
+ base_price_type: PriceBasePriceType;
1075
+ applicable_products: Array<{
1076
+ product_id: string;
1077
+ variant_id?: string;
1078
+ }>;
1079
+ };
1080
+
1081
+ declare const currencyCodeMapping: Record<string, string>;
1082
+ declare const defaultSWRMutationConfiguration: SWRMutationConfiguration<any, any, any, any, any> & {
1083
+ throwOnError?: boolean;
1084
+ };
1085
+ declare const CUSTOMER_ATTRIBUTE_KEY = "_discounts_function_env";
1086
+ declare const CUSTOMER_SCRIPT_GIFT_KEY = "_giveaway_gradient_gifts";
1087
+ declare const CODE_AMOUNT_KEY = "_sku_code_money";
1088
+ declare const SCRIPT_CODE_AMOUNT_KEY = "_code_money";
1089
+ declare const MAIN_PRODUCT_CODE: string[];
1090
+
1091
+ /**
1092
+ * Normalize AddToCartLineItem[] to NormalizedLineItem[] format
1093
+ * This is used to calculate gifts from lines before they are added to cart
1094
+ */
1095
+ declare function normalizeAddToCartLines(lines: AddToCartLineItem[]): NormalizedLineItem[];
1096
+ /**
1097
+ * Create a mock cart structure from AddToCartLineItem[]
1098
+ * This is useful for calculating gifts before actual cart operations
1099
+ */
1100
+ declare function createMockCartFromLines(lines: AddToCartLineItem[], existingCart?: any): any;
1101
+
1102
+ declare const getQuery: () => Record<string, string>;
1103
+
1104
+ declare const getMatchedMainProductSubTotal: (cartData: any, variant_list: AutoFreeGiftMainProduct["variant_id_list"], main_product: AutoFreeGiftMainProduct) => any;
1105
+ declare const safeParse: (str: string) => any;
1106
+ declare const getDiscountEnvAttributeValue: (attributes?: {
1107
+ key: string;
1108
+ value: string;
1109
+ }[]) => any;
1110
+ declare const checkAttributesUpdateNeeded: (oldAttributes: NormalizedAttribute[], newAttributes: NormalizedAttribute[], customAttributesNeedRemove: {
1111
+ key: string;
1112
+ }[]) => boolean;
1113
+ declare function preCheck(rule_conditions: RuleCondition[], userTags: string[], currentDealsTypes: string[]): boolean;
1114
+ declare const formatScriptAutoFreeGift: ({ scriptAutoFreeGiftResult, gradient_gifts, locale, }: {
1115
+ scriptAutoFreeGiftResult: UseScriptAutoFreeGiftResult;
1116
+ gradient_gifts: any;
1117
+ locale: string;
1118
+ }) => any[];
1119
+ declare const formatFunctionAutoFreeGift: ({ qualifyingGift, giftProductsResult, locale, }: {
1120
+ locale: string;
1121
+ qualifyingGift?: FormattedGift | null;
1122
+ giftProductsResult?: NormalizedProduct[] | [];
1123
+ }) => any[];
1124
+
1125
+ interface UseProductOptions extends SWRConfiguration<NormalizedProduct | undefined> {
1126
+ handle?: string;
1127
+ metafieldIdentifiers?: Array<{
1128
+ namespace: string;
1129
+ key: string;
1130
+ }>;
1131
+ }
1132
+ /**
1133
+ * Hook to fetch a single product by handle
1134
+ *
1135
+ * @param options - Hook options including handle and SWR configuration
1136
+ * @returns SWR response with product data
1137
+ *
1138
+ * @example
1139
+ * ```typescript
1140
+ * function ProductPage() {
1141
+ * const { data: product, error, isLoading } = useProduct({
1142
+ * handle: 'my-product'
1143
+ * })
1144
+ *
1145
+ * if (isLoading) return <div>Loading...</div>
1146
+ * if (error) return <div>Error loading product</div>
1147
+ * if (!product) return <div>Product not found</div>
1148
+ *
1149
+ * return (
1150
+ * <div>
1151
+ * <h1>{product.title}</h1>
1152
+ * <p>{product.description}</p>
1153
+ * <p>${product.price.amount}</p>
1154
+ * </div>
1155
+ * )
1156
+ * }
1157
+ * ```
1158
+ */
1159
+ declare function useProduct(options?: UseProductOptions): swr.SWRResponse<NormalizedProduct | undefined, any, SWRConfiguration<NormalizedProduct | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct | undefined>)> | undefined>;
1160
+
1161
+ interface UseAllProductsOptions extends SWRConfiguration<NormalizedProduct[]> {
1162
+ first?: number;
1163
+ query?: string;
1164
+ sortKey?: 'TITLE' | 'PRODUCT_TYPE' | 'VENDOR' | 'UPDATED_AT' | 'CREATED_AT' | 'BEST_SELLING' | 'PRICE' | 'RELEVANCE';
1165
+ reverse?: boolean;
1166
+ metafieldIdentifiers?: Array<{
1167
+ namespace: string;
1168
+ key: string;
1169
+ }>;
1170
+ }
1171
+ /**
1172
+ * Hook to fetch all products
1173
+ *
1174
+ * This hook automatically handles pagination and fetches all products.
1175
+ * Use with caution on stores with many products.
1176
+ *
1177
+ * @param options - Hook options including query parameters and SWR configuration
1178
+ * @returns SWR response with products array
1179
+ *
1180
+ * @example
1181
+ * ```typescript
1182
+ * function ProductList() {
1183
+ * const { data: products, error, isLoading } = useAllProducts({
1184
+ * sortKey: 'TITLE',
1185
+ * reverse: false
1186
+ * })
1187
+ *
1188
+ * if (isLoading) return <div>Loading...</div>
1189
+ * if (error) return <div>Error loading products</div>
1190
+ *
1191
+ * return (
1192
+ * <div>
1193
+ * {products?.map(product => (
1194
+ * <div key={product.id}>
1195
+ * <h2>{product.title}</h2>
1196
+ * <p>${product.price.amount}</p>
1197
+ * </div>
1198
+ * ))}
1199
+ * </div>
1200
+ * )
1201
+ * }
1202
+ * ```
1203
+ */
1204
+ declare function useAllProducts(options?: UseAllProductsOptions): swr.SWRResponse<NormalizedProduct[], any, SWRConfiguration<NormalizedProduct[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>)> | undefined>;
1205
+
1206
+ interface UseProductsByHandlesOptions extends SWRConfiguration<NormalizedProduct[]> {
1207
+ handles?: string[];
1208
+ metafieldIdentifiers?: {
1209
+ product: HasMetafieldsIdentifier[];
1210
+ variant: HasMetafieldsIdentifier[];
1211
+ };
1212
+ }
1213
+ /**
1214
+ * Hook to fetch multiple products by their handles
1215
+ *
1216
+ * @param options - Hook options including handles array and SWR configuration
1217
+ * @returns SWR response with products array
1218
+ *
1219
+ * @example
1220
+ * ```typescript
1221
+ * function FeaturedProducts() {
1222
+ * const { data: products, error, isLoading } = useProductsByHandles({
1223
+ * handles: ['product-1', 'product-2', 'product-3']
1224
+ * })
1225
+ *
1226
+ * if (isLoading) return <div>Loading...</div>
1227
+ * if (error) return <div>Error loading products</div>
1228
+ *
1229
+ * return (
1230
+ * <div>
1231
+ * {products?.map(product => (
1232
+ * <div key={product.id}>
1233
+ * <h2>{product.title}</h2>
1234
+ * <p>${product.price.amount}</p>
1235
+ * </div>
1236
+ * ))}
1237
+ * </div>
1238
+ * )
1239
+ * }
1240
+ * ```
1241
+ */
1242
+ declare function useProductsByHandles(options?: UseProductsByHandlesOptions): swr.SWRResponse<NormalizedProduct[], any, SWRConfiguration<NormalizedProduct[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>)> | undefined>;
1243
+
1244
+ /**
1245
+ * useVariant Hook
1246
+ *
1247
+ * Client-side hook to get the selected variant based on selected options
1248
+ */
1249
+
1250
+ type Options = Record<string, string>;
1251
+ /**
1252
+ * Hook to manage variant selection based on selected options
1253
+ *
1254
+ * @param product - The product object
1255
+ * @param selectedOptions - Currently selected options { Color: 'Red', Size: 'M' }
1256
+ * @returns The matching variant
1257
+ *
1258
+ * @example
1259
+ * ```typescript
1260
+ * function ProductDetail() {
1261
+ * const { data: product } = useProduct({ handle: 'my-product' })
1262
+ * const [selectedOptions, setSelectedOptions] = useState({ Color: 'Red', Size: 'M' })
1263
+ * const variant = useVariant({ product, selectedOptions })
1264
+ *
1265
+ * return (
1266
+ * <div>
1267
+ * <h1>{product.title}</h1>
1268
+ * <p>Selected: {variant.title}</p>
1269
+ * <p>Price: ${variant.price.amount}</p>
1270
+ * <p>Available: {variant.availableForSale ? 'Yes' : 'No'}</p>
1271
+ * </div>
1272
+ * )
1273
+ * }
1274
+ * ```
1275
+ */
1276
+ declare function useVariant({ product, selectedOptions, }: {
1277
+ product?: NormalizedProduct;
1278
+ selectedOptions: Options;
1279
+ }): NormalizedProductVariant | undefined;
1280
+
1281
+ /**
1282
+ * usePrice Hook
1283
+ *
1284
+ * Client-side hook to format price for display
1285
+ */
1286
+ interface UsePriceOptions {
1287
+ amount: number;
1288
+ baseAmount?: number;
1289
+ currencyCode: string;
1290
+ soldOutDescription?: string;
1291
+ maximumFractionDigits?: number;
1292
+ minimumFractionDigits?: number;
1293
+ removeTrailingZeros?: boolean;
1294
+ }
1295
+ interface UsePriceResult {
1296
+ price: string;
1297
+ basePrice?: string;
1298
+ free: boolean;
1299
+ }
1300
+ /**
1301
+ * Hook to format price for display
1302
+ *
1303
+ * @param options - Price formatting options
1304
+ * @returns Formatted price object
1305
+ *
1306
+ * @example
1307
+ * ```typescript
1308
+ * function ProductPrice({ variant }) {
1309
+ * const { price, basePrice, free } = usePrice({
1310
+ * amount: variant.price.amount,
1311
+ * baseAmount: variant.compareAtPrice?.amount,
1312
+ * currencyCode: variant.price.currencyCode
1313
+ * })
1314
+ *
1315
+ * return (
1316
+ * <div>
1317
+ * {free ? (
1318
+ * <span>Free</span>
1319
+ * ) : (
1320
+ * <>
1321
+ * <span className="price">{price}</span>
1322
+ * {basePrice && <span className="original">{basePrice}</span>}
1323
+ * </>
1324
+ * )}
1325
+ * </div>
1326
+ * )
1327
+ * }
1328
+ * ```
1329
+ */
1330
+ declare function usePrice({ amount, baseAmount, currencyCode, soldOutDescription, maximumFractionDigits, minimumFractionDigits, removeTrailingZeros, }: UsePriceOptions): UsePriceResult;
1331
+
1332
+ /**
1333
+ * useSelectedOptions Hook
1334
+ *
1335
+ * Client-side hook to manage selected product options
1336
+ */
1337
+
1338
+ type SelectedOptionsResult = [Options, Dispatch<SetStateAction<Options>>];
1339
+ /**
1340
+ * Hook to manage selected product options based on URL query or SKU
1341
+ *
1342
+ * @param product - The product object
1343
+ * @param sku - Optional SKU to match variant
1344
+ * @returns Tuple of [options, setOptions]
1345
+ *
1346
+ * @example
1347
+ * ```typescript
1348
+ * function ProductDetail() {
1349
+ * const { data: product } = useProduct({ handle: 'my-product' })
1350
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1351
+ * const variant = useVariant({ product, selectedOptions })
1352
+ *
1353
+ * const handleOptionChange = (name: string, value: string) => {
1354
+ * setSelectedOptions(prev => ({ ...prev, [name]: value }))
1355
+ * }
1356
+ *
1357
+ * return (
1358
+ * <div>
1359
+ * {product?.options.map(option => (
1360
+ * <select
1361
+ * key={option.id}
1362
+ * value={selectedOptions[option.name] || ''}
1363
+ * onChange={(e) => handleOptionChange(option.name, e.target.value)}
1364
+ * >
1365
+ * {option.values.map(value => (
1366
+ * <option key={value.label} value={value.label}>
1367
+ * {value.label}
1368
+ * </option>
1369
+ * ))}
1370
+ * </select>
1371
+ * ))}
1372
+ * <p>Selected: {variant?.title}</p>
1373
+ * </div>
1374
+ * )
1375
+ * }
1376
+ * ```
1377
+ */
1378
+ declare function useSelectedOptions(product?: NormalizedProduct, sku?: string): SelectedOptionsResult;
1379
+
1380
+ /**
1381
+ * useProductUrl Hook
1382
+ *
1383
+ * Hook to generate product URLs with variant query params
1384
+ * Requires routerAdapter to be configured in ShopifyProvider
1385
+ */
1386
+
1387
+ /**
1388
+ * Hook to generate product URLs
1389
+ *
1390
+ * @param otherQuery - Additional query parameters to include
1391
+ * @returns Function to generate product URL
1392
+ *
1393
+ * @example
1394
+ * ```typescript
1395
+ * function ProductCard({ product, variant }) {
1396
+ * const getProductUrl = useProductUrl()
1397
+ *
1398
+ * const url = getProductUrl({ product, variant })
1399
+ *
1400
+ * return (
1401
+ * <a href={url}>
1402
+ * <h2>{product.title}</h2>
1403
+ * <p>{variant.title}</p>
1404
+ * </a>
1405
+ * )
1406
+ * }
1407
+ * ```
1408
+ *
1409
+ * @example With additional query params
1410
+ * ```typescript
1411
+ * function ProductCard({ product, variant }) {
1412
+ * const getProductUrl = useProductUrl({ utm_source: 'email' })
1413
+ *
1414
+ * const url = getProductUrl({ product, variant })
1415
+ * // URL will include: ?variant=123&utm_source=email
1416
+ *
1417
+ * return <a href={url}>{product.title}</a>
1418
+ * }
1419
+ * ```
1420
+ */
1421
+ declare function useProductUrl(otherQuery?: Record<string, string>): ({ product, variant }: {
1422
+ product?: NormalizedProduct;
1423
+ variant?: NormalizedProductVariant;
1424
+ }) => string;
1425
+
1426
+ /**
1427
+ * useUpdateVariantQuery Hook
1428
+ *
1429
+ * Hook to automatically update URL query string when variant changes
1430
+ */
1431
+
1432
+ /**
1433
+ * Hook to update URL query string when variant changes
1434
+ *
1435
+ * This hook automatically updates the browser URL with the selected variant ID
1436
+ * without causing a page reload. Useful for shareable URLs and browser history.
1437
+ *
1438
+ * @param variant - The selected variant
1439
+ *
1440
+ * @example
1441
+ * ```typescript
1442
+ * function ProductDetail() {
1443
+ * const { data: product } = useProduct({ handle: 'my-product' })
1444
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1445
+ * const variant = useVariant({ product, selectedOptions })
1446
+ *
1447
+ * // Automatically updates URL when variant changes
1448
+ * useUpdateVariantQuery(variant)
1449
+ *
1450
+ * return (
1451
+ * <div>
1452
+ * <h1>{product?.title}</h1>
1453
+ * <p>Current variant: {variant?.title}</p>
1454
+ * {/* URL will be: /products/my-product?variant=123456 *\/}
1455
+ * </div>
1456
+ * )
1457
+ * }
1458
+ * ```
1459
+ */
1460
+ declare function useUpdateVariantQuery(variant?: NormalizedProductVariant): void;
1461
+
1462
+ /**
1463
+ * useVariantMedia Hook
1464
+ *
1465
+ * Hook to get media (images and videos) for the selected variant
1466
+ */
1467
+
1468
+ type ImageMedia = Media & {
1469
+ mediaContentType: 'IMAGE';
1470
+ };
1471
+ type VideoMedia = Media & {
1472
+ mediaContentType: 'VIDEO' | 'EXTERNAL_VIDEO';
1473
+ };
1474
+ interface VariantMedia {
1475
+ productList: ImageMedia[];
1476
+ sceneList: ImageMedia[];
1477
+ videoList: VideoMedia[];
1478
+ }
1479
+ /**
1480
+ * Hook to get media for the selected variant
1481
+ *
1482
+ * @param product - The product object
1483
+ * @param variant - The selected variant
1484
+ * @returns Object with productList (first image), sceneList (other images), videoList
1485
+ *
1486
+ * @example
1487
+ * ```typescript
1488
+ * function ProductGallery() {
1489
+ * const { data: product } = useProduct({ handle: 'my-product' })
1490
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1491
+ * const variant = useVariant({ product, selectedOptions })
1492
+ * const { productList, sceneList, videoList } = useVariantMedia({ product, variant })
1493
+ *
1494
+ * return (
1495
+ * <div>
1496
+ * {/* Main product image *\/}
1497
+ * {productList.map(media => (
1498
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1499
+ * ))}
1500
+ *
1501
+ * {/* Scene/detail images *\/}
1502
+ * {sceneList.map(media => (
1503
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1504
+ * ))}
1505
+ *
1506
+ * {/* Videos *\/}
1507
+ * {videoList.map(media => (
1508
+ * <video key={media.id} src={media.sources?.[0]?.url} controls />
1509
+ * ))}
1510
+ * </div>
1511
+ * )
1512
+ * }
1513
+ * ```
1514
+ */
1515
+ declare function useVariantMedia({ product, variant, }: {
1516
+ product?: NormalizedProduct;
1517
+ variant?: NormalizedProductVariant;
1518
+ }): VariantMedia;
1519
+
1520
+ interface UseCollectionOptions extends SWRConfiguration<NormalizedCollection | undefined> {
1521
+ handle?: string;
1522
+ metafieldIdentifiers?: Array<{
1523
+ namespace: string;
1524
+ key: string;
1525
+ }>;
1526
+ }
1527
+ declare function useCollection(options?: UseCollectionOptions): swr.SWRResponse<NormalizedCollection | undefined, any, SWRConfiguration<NormalizedCollection | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection | undefined>)> | undefined>;
1528
+
1529
+ interface UseAllCollectionsOptions extends SWRConfiguration<NormalizedCollection[]> {
1530
+ first?: number;
1531
+ query?: string;
1532
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1533
+ reverse?: boolean;
1534
+ metafieldIdentifiers?: Array<{
1535
+ namespace: string;
1536
+ key: string;
1537
+ }>;
1538
+ }
1539
+ declare function useAllCollections(options?: UseAllCollectionsOptions): swr.SWRResponse<NormalizedCollection[], any, SWRConfiguration<NormalizedCollection[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection[]>)> | undefined>;
1540
+
1541
+ interface UseCollectionsOptions extends SWRConfiguration<CollectionsConnection> {
1542
+ first?: number;
1543
+ after?: string;
1544
+ query?: string;
1545
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1546
+ reverse?: boolean;
1547
+ metafieldIdentifiers?: Array<{
1548
+ namespace: string;
1549
+ key: string;
1550
+ }>;
1551
+ }
1552
+ declare function useCollections(options?: UseCollectionsOptions): swr.SWRResponse<CollectionsConnection, any, SWRConfiguration<CollectionsConnection, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<CollectionsConnection>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<CollectionsConnection>)> | undefined>;
1553
+
1554
+ interface UseBlogOptions extends SWRConfiguration<NormalizedBlog | undefined> {
1555
+ handle?: string;
1556
+ metafieldIdentifiers?: Array<{
1557
+ namespace: string;
1558
+ key: string;
1559
+ }>;
1560
+ }
1561
+ declare function useBlog(options?: UseBlogOptions): swr.SWRResponse<NormalizedBlog | undefined, any, SWRConfiguration<NormalizedBlog | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog | undefined>)> | undefined>;
1562
+
1563
+ interface UseAllBlogsOptions extends SWRConfiguration<NormalizedBlog[]> {
1564
+ first?: number;
1565
+ query?: string;
1566
+ metafieldIdentifiers?: Array<{
1567
+ namespace: string;
1568
+ key: string;
1569
+ }>;
1570
+ }
1571
+ declare function useAllBlogs(options?: UseAllBlogsOptions): swr.SWRResponse<NormalizedBlog[], any, SWRConfiguration<NormalizedBlog[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog[]>)> | undefined>;
1572
+
1573
+ interface UseArticleOptions extends SWRConfiguration<NormalizedArticle | undefined> {
1574
+ blogHandle?: string;
1575
+ articleHandle?: string;
1576
+ metafieldIdentifiers?: Array<{
1577
+ namespace: string;
1578
+ key: string;
1579
+ }>;
1580
+ }
1581
+ declare function useArticle(options?: UseArticleOptions): swr.SWRResponse<NormalizedArticle | undefined, any, SWRConfiguration<NormalizedArticle | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle | undefined>)> | undefined>;
1582
+
1583
+ interface UseArticlesOptions extends SWRConfiguration<NormalizedArticle[]> {
1584
+ first?: number;
1585
+ query?: string;
1586
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1587
+ reverse?: boolean;
1588
+ metafieldIdentifiers?: Array<{
1589
+ namespace: string;
1590
+ key: string;
1591
+ }>;
1592
+ }
1593
+ declare function useArticles(options?: UseArticlesOptions): swr.SWRResponse<NormalizedArticle[], any, SWRConfiguration<NormalizedArticle[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>)> | undefined>;
1594
+
1595
+ interface UseArticlesInBlogOptions extends SWRConfiguration<NormalizedArticle[]> {
1596
+ blogHandle?: string;
1597
+ first?: number;
1598
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1599
+ reverse?: boolean;
1600
+ metafieldIdentifiers?: Array<{
1601
+ namespace: string;
1602
+ key: string;
1603
+ }>;
1604
+ }
1605
+ declare function useArticlesInBlog(options?: UseArticlesInBlogOptions): swr.SWRResponse<NormalizedArticle[], any, SWRConfiguration<NormalizedArticle[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>)> | undefined>;
1606
+
1607
+ type SearchResultType = 'ARTICLE' | 'PAGE' | 'PRODUCT';
1608
+ interface NormalizedSearchResultItem {
1609
+ type: SearchResultType;
1610
+ id?: string;
1611
+ handle?: string;
1612
+ title?: string;
1613
+ description?: string;
1614
+ url?: string;
1615
+ image?: {
1616
+ url: string;
1617
+ altText?: string;
1618
+ };
1619
+ }
1620
+ interface SearchResult {
1621
+ items: NormalizedSearchResultItem[];
1622
+ totalCount: number;
1623
+ pageInfo?: {
1624
+ hasNextPage: boolean;
1625
+ endCursor?: string;
1626
+ };
1627
+ }
1628
+ interface UseSearchOptions extends SWRConfiguration<SearchResult | undefined> {
1629
+ query?: string;
1630
+ first?: number;
1631
+ types?: SearchResultType[];
1632
+ productFilters?: any[];
1633
+ }
1634
+ declare function useSearch(options?: UseSearchOptions): swr.SWRResponse<SearchResult | undefined, any, SWRConfiguration<SearchResult | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>)> | undefined>;
1635
+
1636
+ interface SiteInfo {
1637
+ name: string;
1638
+ description?: string;
1639
+ primaryDomain: {
1640
+ url: string;
1641
+ host: string;
1642
+ };
1643
+ brand?: {
1644
+ logo?: {
1645
+ image?: {
1646
+ url: string;
1647
+ };
1648
+ };
1649
+ colors?: {
1650
+ primary?: string;
1651
+ secondary?: string;
1652
+ };
1653
+ };
1654
+ metafields?: Record<string, any>;
1655
+ }
1656
+ interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
1657
+ metafieldIdentifiers?: Array<{
1658
+ namespace: string;
1659
+ key: string;
1660
+ }>;
1661
+ }
1662
+ declare function useSite(options?: UseSiteOptions): swr.SWRResponse<SiteInfo | undefined, any, SWRConfiguration<SiteInfo | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SiteInfo | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SiteInfo | undefined>)> | undefined>;
1663
+
1664
+ /**
1665
+ * useIntersection Hook
1666
+ *
1667
+ * Observes element visibility using IntersectionObserver API
1668
+ */
1669
+
1670
+ interface UseIntersectionOptions {
1671
+ /** Callback function when element becomes visible */
1672
+ callback: () => void;
1673
+ /** Only trigger callback once (default: false) */
1674
+ once?: boolean;
1675
+ /** Root element for intersection (default: viewport) */
1676
+ root?: Element | null;
1677
+ /** Margin around root (default: '0px') */
1678
+ rootMargin?: string;
1679
+ /** Visibility threshold 0-1 (default: 0.8) */
1680
+ threshold?: number;
1681
+ }
1682
+ /**
1683
+ * Hook to observe element visibility with IntersectionObserver
1684
+ *
1685
+ * Triggers a callback when the target element becomes visible in the viewport
1686
+ *
1687
+ * @param targetRef - React ref to the target element
1688
+ * @param options - Intersection observer options
1689
+ *
1690
+ * @example
1691
+ * ```typescript
1692
+ * function LazyImage() {
1693
+ * const imageRef = useRef<HTMLImageElement>(null)
1694
+ * const [loaded, setLoaded] = useState(false)
1695
+ *
1696
+ * useIntersection(imageRef, {
1697
+ * callback: () => setLoaded(true),
1698
+ * once: true,
1699
+ * threshold: 0.5
1700
+ * })
1701
+ *
1702
+ * return (
1703
+ * <img
1704
+ * ref={imageRef}
1705
+ * src={loaded ? actualSrc : placeholderSrc}
1706
+ * alt="Lazy loaded"
1707
+ * />
1708
+ * )
1709
+ * }
1710
+ * ```
1711
+ */
1712
+ declare function useIntersection(targetRef: RefObject<Element> | undefined, options: UseIntersectionOptions): void;
1713
+
1714
+ /**
1715
+ * useExposure Hook
1716
+ *
1717
+ * Tracks element exposure (visibility + duration) for analytics/tracking
1718
+ */
1719
+
1720
+ interface UseExposureOptions {
1721
+ /** Visibility threshold 0-1 (default: 0.5, meaning 50% visible) */
1722
+ threshold?: number;
1723
+ /** Duration in milliseconds element must be visible (default: 2000ms) */
1724
+ duration?: number;
1725
+ /** Only trigger callback once (default: true) */
1726
+ once?: boolean;
1727
+ /** Callback when element has been exposed for the required duration */
1728
+ onExposure: () => void;
1729
+ }
1730
+ /**
1731
+ * Hook to track element exposure (visibility + duration threshold)
1732
+ *
1733
+ * Useful for tracking ad impressions, product views, or any analytics
1734
+ * that require an element to be visible for a certain duration
1735
+ *
1736
+ * @param targetRef - React ref to the target element
1737
+ * @param options - Exposure tracking options
1738
+ * @returns Current visibility state
1739
+ *
1740
+ * @example
1741
+ * ```typescript
1742
+ * function ProductCard({ product }) {
1743
+ * const cardRef = useRef<HTMLDivElement>(null)
1744
+ *
1745
+ * const isVisible = useExposure(cardRef, {
1746
+ * threshold: 0.5, // 50% visible
1747
+ * duration: 2000, // 2 seconds
1748
+ * once: true, // Only track once
1749
+ * onExposure: () => {
1750
+ * // Track product impression
1751
+ * analytics.track('Product Viewed', {
1752
+ * productId: product.id,
1753
+ * productName: product.title
1754
+ * })
1755
+ * }
1756
+ * })
1757
+ *
1758
+ * return (
1759
+ * <div ref={cardRef}>
1760
+ * {product.title}
1761
+ * {isVisible && <div className="viewing-indicator" />}
1762
+ * </div>
1763
+ * )
1764
+ * }
1765
+ * ```
1766
+ */
1767
+ declare function useExposure(targetRef: RefObject<Element>, options: UseExposureOptions): boolean;
1768
+
1769
+ /**
1770
+ * useGeoLocation Hook
1771
+ *
1772
+ * Fetches and caches user's geographic location
1773
+ */
1774
+
1775
+ interface GeoLocationData {
1776
+ /** Geographic information */
1777
+ geo: {
1778
+ /** Country information */
1779
+ country?: {
1780
+ /** Country code (e.g., 'US', 'GB') */
1781
+ code?: string;
1782
+ /** Country name */
1783
+ name?: string;
1784
+ };
1785
+ /** Region/state information */
1786
+ region?: {
1787
+ code?: string;
1788
+ name?: string;
1789
+ };
1790
+ /** City name */
1791
+ city?: string;
1792
+ /** Coordinates */
1793
+ latitude?: number;
1794
+ longitude?: number;
1795
+ /** Timezone */
1796
+ timezone?: string;
1797
+ };
1798
+ /** Suggested locale based on location */
1799
+ suggestLocale?: string;
1800
+ }
1801
+ interface LocaleMapping {
1802
+ /** Countries that should map to EU locale */
1803
+ euCountries?: string[];
1804
+ /** Countries that should map to DE locale */
1805
+ deCountries?: string[];
1806
+ /** Countries that should map to AU locale */
1807
+ auCountries?: string[];
1808
+ /** Countries that should map to AE-EN locale */
1809
+ aeEnCountries?: string[];
1810
+ /** Custom country to locale mapping */
1811
+ customMapping?: Record<string, string>;
1812
+ }
1813
+ interface UseGeoLocationOptions extends SWRConfiguration<GeoLocationData | undefined> {
1814
+ /** API endpoint for fetching geo data (default: '/geolocation') */
1815
+ endpoint?: string;
1816
+ /** Cache key for localStorage (default: 'geoLocation') */
1817
+ cacheKey?: string;
1818
+ /** Cache duration in milliseconds (default: 24 hours) */
1819
+ cacheDuration?: number;
1820
+ /** Locale mapping configuration */
1821
+ localeMapping?: LocaleMapping;
1822
+ /** Enable automatic caching (default: true) */
1823
+ enableCache?: boolean;
1824
+ }
1825
+ /**
1826
+ * Hook to fetch and cache user's geographic location
1827
+ *
1828
+ * Fetches geo data from an API endpoint and caches it in localStorage
1829
+ * Automatically determines suggested locale based on country
1830
+ *
1831
+ * @param options - Geo location options
1832
+ * @returns SWR response with geo location data
1833
+ *
1834
+ * @example
1835
+ * ```typescript
1836
+ * function LocaleSwitcher() {
1837
+ * const { data: geoData, error, isLoading } = useGeoLocation({
1838
+ * endpoint: '/api/geolocation',
1839
+ * localeMapping: {
1840
+ * euCountries: ['FR', 'DE', 'IT', 'ES'],
1841
+ * auCountries: ['AU', 'NZ']
1842
+ * }
1843
+ * })
1844
+ *
1845
+ * if (isLoading) return <div>Loading...</div>
1846
+ * if (error) return <div>Error loading location</div>
1847
+ *
1848
+ * return (
1849
+ * <div>
1850
+ * <p>Country: {geoData?.geo.country?.code}</p>
1851
+ * <p>Suggested Locale: {geoData?.suggestLocale}</p>
1852
+ * </div>
1853
+ * )
1854
+ * }
1855
+ * ```
1856
+ *
1857
+ * @example
1858
+ * ```typescript
1859
+ * // With custom locale mapping
1860
+ * const { data } = useGeoLocation({
1861
+ * localeMapping: {
1862
+ * customMapping: {
1863
+ * 'JP': 'ja',
1864
+ * 'CN': 'zh-cn',
1865
+ * 'TW': 'zh-tw'
1866
+ * }
1867
+ * }
1868
+ * })
1869
+ * ```
1870
+ */
1871
+ declare function useGeoLocation(options?: UseGeoLocationOptions): ReturnType<typeof swr__default<GeoLocationData | undefined>>;
1872
+ /**
1873
+ * Get cached geo location data without fetching
1874
+ *
1875
+ * @param cacheKey - Cache key (default: 'geoLocation')
1876
+ * @returns Cached geo data or undefined
1877
+ *
1878
+ * @example
1879
+ * ```typescript
1880
+ * const cachedGeo = getCachedGeoLocation()
1881
+ * if (cachedGeo) {
1882
+ * console.log('Country:', cachedGeo.geo.country?.code)
1883
+ * }
1884
+ * ```
1885
+ */
1886
+ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | undefined;
1887
+ /**
1888
+ * Clear cached geo location data
1889
+ *
1890
+ * @param cacheKey - Cache key (default: 'geoLocation')
1891
+ *
1892
+ * @example
1893
+ * ```typescript
1894
+ * clearGeoLocationCache()
1895
+ * ```
1896
+ */
1897
+ declare function clearGeoLocationCache(cacheKey?: string): void;
1898
+
1899
+ export { type AddCartLinesInput, AddToCartLineItem, type ApplyCartCodesInput, type AutoFreeGift, type AutoFreeGiftCartLineInput, type AutoFreeGiftConfig, type AutoFreeGiftItem, type AutoFreeGiftList, type AutoFreeGiftMainProduct, type BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, type Config, type CreateCartInput, DeliveryData, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, type MainProductInfo, type NormalizedSearchResultItem, type Options, OrderBasePriceType, type OrderDiscountConfig, type OrderDiscountResult, OrderDiscountType, PlusMemberContext, type PlusMemberContextValue, PlusMemberProvider, type PlusMemberProviderProps, PlusMemberSettingsMetafields, PlusMemberShippingMethodConfig, PriceBasePriceType, type PriceDiscountConfig, PriceDiscountType, type RemoveCartCodesInput, type RemoveCartLinesInput, type RewardItem, type RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, type SearchResult, type SearchResultType, type SelectedOptionsResult, SelectedPlusMemberProduct, type ShippingMethodsContext, type SiteInfo, SpendMoneyType, type TieredDiscount, type UpdateCartAttributesInput, type UseAllBlogsOptions, type UseAllCollectionsOptions, type UseAllProductsOptions, type UseArticleOptions, type UseArticlesInBlogOptions, type UseArticlesOptions, type UseAutoRemovePlusMemberInCartProps, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseHasPlusMemberInCartProps, type UseIntersectionOptions, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdatePlusMemberDeliveryOptionsProps, type VariantItem, type VariantMedia, type VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines, useAddPlusMemberProductsToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };