@anker-in/shopify-react 0.1.1-beta.14 → 0.1.1-beta.16

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,1881 @@
1
- export { A as AddCartLinesInput, d as ApplyCartCodesInput, w as AutoFreeGift, y as AutoFreeGiftConfig, Q as AutoFreeGiftItem, T as AutoFreeGiftList, x as AutoFreeGiftMainProduct, B as BuyNowInput, K as BuyRuleType, a5 as CODE_AMOUNT_KEY, a3 as CUSTOMER_ATTRIBUTE_KEY, a4 as CUSTOMER_SCRIPT_GIFT_KEY, P as CartLineInput, E as Config, C as CreateCartInput, D as DiscountLabel, N as FormattedGift, L as FunctionGiftResult, br as GeoLocationData, G as GiftProduct, I as GiftProductItem, F as GiftTier, bi as HasPlusMemberInCartResult, az as ImageMedia, bs as LocaleMapping, a7 as MAIN_PRODUCT_CODE, M as MainProductInfo, as as Options, X as OrderBasePriceType, Z as OrderDiscountConfig, O as OrderDiscountResult, W as OrderDiscountType, b1 as PlusMemberContext, b0 as PlusMemberContextValue, bm as PlusMemberProvider, bl as PlusMemberProviderProps, $ as PriceBasePriceType, a0 as PriceDiscountConfig, _ as PriceDiscountType, f as RemoveCartCodesInput, R as RemoveCartLinesInput, H as RewardItem, z as RuleCondition, J as RuleType, a6 as SCRIPT_CODE_AMOUNT_KEY, aV as SearchResult, aU as SearchResultItem, aT as SearchResultType, al as SelectedOptionsResult, a$ as ShippingMethodsContext, aY as SiteInfo, S as SpendMoneyType, Y as TieredDiscount, U as UpdateCartAttributesInput, aL as UseAllBlogsOptions, aF as UseAllCollectionsOptions, ao as UseAllProductsOptions, aN as UseArticleOptions, aR as UseArticlesInBlogOptions, aP as UseArticlesOptions, bf as UseAutoRemovePlusMemberInCartProps, aJ as UseBlogOptions, i as UseBuyNowOptions, l as UseCalcGiftsFromLinesOptions, m as UseCalcGiftsFromLinesResult, aD as UseCollectionOptions, aH as UseCollectionsOptions, bp as UseExposureOptions, bt as UseGeoLocationOptions, bh as UseHasPlusMemberInCartProps, bn as UseIntersectionOptions, au as UsePriceOptions, av as UsePriceResult, am as UseProductOptions, aq as UseProductsByHandlesOptions, s as UseScriptAutoFreeGiftResult, aW as UseSearchOptions, b5 as UseShippingMethodsOptions, b6 as UseShippingMethodsResult, aZ as UseSiteOptions, bb as UseUpdatePlusMemberDeliveryOptionsProps, V as VariantItem, aB as VariantMedia, aA as VideoMedia, a9 as atobID, aa as btoaID, ag as checkAttributesUpdateNeeded, bw as clearGeoLocationCache, ac as createMockCartFromLines, a1 as currencyCodeMapping, a2 as defaultSWRMutationConfiguration, aj as formatFunctionAutoFreeGift, ai as formatScriptAutoFreeGift, bv as getCachedGeoLocation, af as getDiscountEnvAttributeValue, ad as getMatchedMainProductSubTotal, a8 as getQuery, p as getReferralAttributes, ab as normalizeAddToCartLines, ah as preCheck, ae as safeParse, a as useAddCartLines, bk as useAddPlusMemberProductsToCart, aM as useAllBlogs, aG as useAllCollections, ap as useAllProducts, e as useApplyCartCodes, aO as useArticle, aQ as useArticles, aS as useArticlesInBlog, bg as useAutoRemovePlusMemberInCart, aK as useBlog, j as useBuyNow, k as useCalcAutoFreeGift, n as useCalcGiftsFromLines, o as useCalcOrderDiscount, q as useCartAttributes, r as useCartItemQuantityLimit, aE as useCollection, aI as useCollections, u as useCreateCart, bq as useExposure, bu as useGeoLocation, bj as useHasPlusMemberInCart, bo as useIntersection, b4 as usePlusAnnualProductVariant, be as usePlusMemberCheckoutCustomAttributes, b2 as usePlusMemberContext, ba as usePlusMemberDeliveryCodes, bd as usePlusMemberItemCustomAttributes, b3 as usePlusMonthlyProductVariant, aw as usePrice, an as useProduct, ax as useProductUrl, ar as useProductsByHandles, g as useRemoveCartCodes, c as useRemoveCartLines, b9 as useReplaceCartPlusMember, t as useScriptAutoFreeGift, aX as useSearch, ak as useSelectedOptions, b8 as useShippingMethodAvailableCheck, b7 as useShippingMethods, a_ as useSite, h as useUpdateCartAttributes, b as useUpdateCartLines, v as useUpdateLineCodeAmountAttributes, bc as useUpdatePlusMemberDeliveryOptions, ay as useUpdateVariantQuery, at as useVariant, aC as useVariantMedia } from '../index-Bp9gEGUb.mjs';
2
- export { a as AddToCartInput, A as AddToCartLineItem, g as DeliveryCustomData, h as DeliveryData, 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-DpxtE_nv.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 as CartLineInput$1, 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-DX-2ABDs.mjs';
6
+ export { a as AddToCartInput, g as DeliveryCustomData, M as MailingAddress, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, c as PlusMemberShippingMethodMetafields, S as ShippingMethodMode, U as UseAddToCartOptions, u as useAddToCart } from '../types-DX-2ABDs.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$1[];
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$1[];
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: CartLineInput[];
407
+ }
408
+ interface CartLineInput {
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: CartLineInput[];
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
+ };
562
+ order_discount_conf: {
563
+ base_price: OrderBasePriceType;
564
+ tiered_discounts: TieredDiscount[];
565
+ };
566
+ };
567
+ };
568
+
569
+ interface OrderDiscountResult {
570
+ qualifyingDiscount: TieredDiscount | null;
571
+ nextTierGoal: TieredDiscount | null;
572
+ activeCampaign: OrderDiscountConfig | null;
573
+ discountAmount: number;
574
+ cartTotalForDiscount: number;
575
+ isLoading: boolean;
576
+ }
577
+ /**
578
+ * [计算型 Hook]
579
+ * 根据购物车、活动配置和用户信息,计算出应得的订单折扣和下一个目标。
580
+ * 此 Hook 不产生任何副作用。
581
+ * 使用示例:
582
+ * const { qualifyingDiscount, nextTierGoal, activeCampaign, discountAmount, isLoading } = useCalcOrderDiscount(cart, orderDiscountConfig);
583
+ * @param cart - 购物车
584
+ * @param orderDiscountConfig - 订单折扣配置
585
+ * @returns { OrderDiscountResult }
586
+ */
587
+ declare const useCalcOrderDiscount: (cart: any, orderDiscountConfig: OrderDiscountConfig[], customer: any) => OrderDiscountResult;
588
+
589
+ interface ShippingMethodsContext {
590
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
591
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
592
+ nddOverweight: boolean;
593
+ tddOverweight: boolean;
594
+ }
595
+ interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile = any> {
596
+ plusMemberMetafields: PlusMemberSettingsMetafields;
597
+ shopCommon?: Record<string, any>;
598
+ zipCode: string;
599
+ setZipCode: (value: string) => void;
600
+ allowNextDayDelivery: boolean;
601
+ setAllowNextDayDelivery: (value: boolean) => void;
602
+ allowThirdDayDelivery: boolean;
603
+ setAllowThirdDayDelivery: (value: boolean) => void;
604
+ selectedPlusMemberMode: DeliveryPlusType;
605
+ setSelectedPlusMemberMode: (value: DeliveryPlusType) => void;
606
+ showAreaCheckModal: boolean;
607
+ setShowAreaCheckModal: (value: boolean) => void;
608
+ selectedShippingMethod?: PlusMemberShippingMethodConfig;
609
+ setSelectedShippingMethod: (value: PlusMemberShippingMethodConfig) => void;
610
+ showTip: boolean;
611
+ setShowTip: (value: boolean) => void;
612
+ showMoreShippingMethod: boolean;
613
+ setShowMoreShippingMethod: (value: boolean) => void;
614
+ variant: TVariant;
615
+ product: TProduct;
616
+ shippingMethodsContext: ShippingMethodsContext;
617
+ selectedPlusMemberProduct: SelectedPlusMemberProduct;
618
+ plusMemberProducts: NormalizedProduct[];
619
+ showPlusMemberBenefit: boolean;
620
+ setShowPlusMemberBenefit: (value: boolean) => void;
621
+ deleteMarginBottom: boolean;
622
+ setDeleteMarginBottom: (value: boolean) => void;
623
+ profile?: TProfile;
624
+ locale?: string;
625
+ }
626
+ declare const PlusMemberContext: React$1.Context<PlusMemberContextValue<any, any, any>>;
627
+
628
+ /**
629
+ * Hook to access Plus Member Context
630
+ */
631
+ declare function usePlusMemberContext<TProduct = any, TVariant = any>(): PlusMemberContextValue<any, any, any>;
632
+
633
+ /**
634
+ * Hook to get Plus Monthly Product Variant
635
+ */
636
+ declare function usePlusMonthlyProductVariant<TVariant = any>(): TVariant | undefined;
637
+
638
+ /**
639
+ * Hook to get Plus Annual Product Variant
640
+ */
641
+ declare function usePlusAnnualProductVariant<TVariant = any>(): TVariant | undefined;
642
+
643
+ /**
644
+ * Hook to calculate available shipping methods based on product weight and member status
645
+ */
646
+
647
+ interface UseShippingMethodsOptions<TVariant = any> {
648
+ /** Product variant with weight information */
649
+ variant: TVariant;
650
+ /** Zip code for delivery */
651
+ zipCode: string;
652
+ /** Whether next day delivery is allowed */
653
+ allowNextDayDelivery: boolean;
654
+ /** Whether third day delivery is allowed */
655
+ allowThirdDayDelivery: boolean;
656
+ /** Plus member metafields configuration */
657
+ plusMemberMetafields: PlusMemberSettingsMetafields;
658
+ /** Selected plus member mode */
659
+ selectedPlusMemberMode: DeliveryPlusType;
660
+ /** Whether user is a plus member */
661
+ isPlus?: boolean;
662
+ /** Available NDD coupon code */
663
+ nddCoupon?: string;
664
+ /** Available TDD coupon code */
665
+ tddCoupon?: string;
666
+ }
667
+ interface UseShippingMethodsResult {
668
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
669
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
670
+ nddOverweight: boolean;
671
+ tddOverweight: boolean;
672
+ }
673
+ /**
674
+ * Calculate available shipping methods based on product weight, member status, and available coupons
675
+ *
676
+ * @param options - Configuration options
677
+ * @returns Shipping methods categorized by free/payment and overweight status
678
+ *
679
+ * @example
680
+ * ```tsx
681
+ * const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
682
+ * variant,
683
+ * zipCode,
684
+ * allowNextDayDelivery,
685
+ * allowThirdDayDelivery,
686
+ * plusMemberMetafields,
687
+ * selectedPlusMemberMode,
688
+ * isPlus: profile?.isPlus,
689
+ * nddCoupon,
690
+ * tddCoupon,
691
+ * })
692
+ * ```
693
+ */
694
+ declare function useShippingMethods<TVariant extends {
695
+ weight?: number;
696
+ } = any>(options: UseShippingMethodsOptions<TVariant>): UseShippingMethodsResult;
697
+
698
+ /**
699
+ * Hook to check shipping method availability and automatically adjust selection
700
+ */
701
+ declare function useShippingMethodAvailableCheck(): void;
702
+
703
+ /**
704
+ * Hook to replace cart plus member product
705
+ *
706
+ * When adding a monthly membership while an annual membership exists in cart,
707
+ * the annual membership will be replaced and vice versa.
708
+ *
709
+ * @returns Handler function to replace conflicting membership products
710
+ *
711
+ * @example
712
+ * ```tsx
713
+ * const replaceCartPlusMember = useReplaceCartPlusMember()
714
+ *
715
+ * // Call before adding new membership product
716
+ * await replaceCartPlusMember()
717
+ * ```
718
+ */
719
+ declare const useReplaceCartPlusMember: () => () => Promise<void>;
720
+
721
+ /**
722
+ * Hook to get delivery discount codes from delivery data
723
+ *
724
+ * Extracts and returns the discount codes from the delivery custom data.
725
+ *
726
+ * @param deliveryData - Delivery data containing custom attributes
727
+ * @returns Array of discount codes or undefined
728
+ *
729
+ * @example
730
+ * ```tsx
731
+ * const deliveryCodes = usePlusMemberDeliveryCodes({ deliveryData })
732
+ * ```
733
+ */
734
+ declare const usePlusMemberDeliveryCodes: ({ deliveryData, }: {
735
+ deliveryData?: DeliveryData;
736
+ }) => string[] | undefined;
737
+
738
+ interface UseUpdatePlusMemberDeliveryOptionsProps {
739
+ /** SWR mutation configuration */
740
+ options?: SWRMutationConfiguration<any, Error, 'update-cart-delivery-options', {
741
+ deliveryData: DeliveryData;
742
+ }>;
743
+ }
744
+ /**
745
+ * Hook to update cart delivery options based on plus member delivery data
746
+ *
747
+ * This hook extracts the selected delivery option from delivery custom data and
748
+ * maps it to the appropriate delivery option handle from the cart's deliveryGroups.
749
+ * It then triggers the update-cart-delivery-options mutation to apply the selection.
750
+ *
751
+ * The hook handles:
752
+ * - Extracting delivery option code from deliveryCustomData.selected_delivery_option
753
+ * - Finding the matching delivery option in cart.deliveryGroups
754
+ * - Triggering the cart update with the correct delivery option handle
755
+ *
756
+ * @param props - Hook properties
757
+ * @returns useSWRMutation result with trigger and loading state
758
+ *
759
+ * @example
760
+ * ```tsx
761
+ * const { trigger, isMutating } = useUpdatePlusMemberDeliveryOptions()
762
+ *
763
+ * // Trigger update with delivery data
764
+ * await trigger({ deliveryData })
765
+ * ```
766
+ */
767
+ declare const useUpdatePlusMemberDeliveryOptions: ({ options, }?: UseUpdatePlusMemberDeliveryOptionsProps) => swr_mutation.SWRMutationResponse<any, Error, "update-cart-delivery-options", {
768
+ deliveryData: DeliveryData;
769
+ }>;
770
+
771
+ /**
772
+ * Hook to generate custom attributes for cart line items
773
+ *
774
+ * Creates custom attributes based on delivery data to be attached to line items.
775
+ *
776
+ * @param deliveryData - Delivery data containing custom attributes
777
+ * @returns Array of custom attributes for line items
778
+ *
779
+ * @example
780
+ * ```tsx
781
+ * const itemAttributes = usePlusMemberItemCustomAttributes({ deliveryData })
782
+ *
783
+ * // Use in addToCart
784
+ * await addToCart({
785
+ * lineItems: lineItems.map(item => ({
786
+ * ...item,
787
+ * customAttributes: [...(item.customAttributes || []), ...itemAttributes]
788
+ * }))
789
+ * })
790
+ * ```
791
+ */
792
+ declare const usePlusMemberItemCustomAttributes: ({ deliveryData, }: {
793
+ deliveryData?: DeliveryData;
794
+ }) => NormalizedAttribute[];
795
+
796
+ /**
797
+ * Hook to generate custom attributes for checkout
798
+ *
799
+ * Creates custom attributes based on delivery data, profile, and customer information
800
+ * to be attached to the checkout.
801
+ *
802
+ * Requires profile to be provided via PlusMemberContext.
803
+ *
804
+ * @param deliveryData - Delivery data containing custom attributes
805
+ * @param product - Product information (optional, for hiding shipping benefits check)
806
+ * @param variant - Variant information (optional, for presale and hiding shipping benefits check)
807
+ * @param isShowShippingBenefits - Function to check if shipping benefits should be shown (optional)
808
+ * @returns Array of custom attributes for checkout
809
+ *
810
+ * @example
811
+ * ```tsx
812
+ * const checkoutAttributes = usePlusMemberCheckoutCustomAttributes({
813
+ * deliveryData,
814
+ * product,
815
+ * variant,
816
+ * customer,
817
+ * isShowShippingBenefits
818
+ * })
819
+ *
820
+ * // Use in checkout
821
+ * await createCheckout({
822
+ * lineItems,
823
+ * customAttributes: checkoutAttributes
824
+ * })
825
+ * ```
826
+ */
827
+ declare const usePlusMemberCheckoutCustomAttributes: <TProduct = any, TVariant = any>({ deliveryData, product, variant, isShowShippingBenefits, }: {
828
+ deliveryData?: DeliveryData;
829
+ product?: TProduct;
830
+ variant?: TVariant;
831
+ isShowShippingBenefits?: (args: {
832
+ variant?: TVariant;
833
+ product?: TProduct;
834
+ setting: any;
835
+ }) => boolean;
836
+ }) => NormalizedAttribute[];
837
+
838
+ /**
839
+ * useAutoRemovePlusMemberInCart Hook
840
+ * 付费会员身份自动移除购物车中的会员产品
841
+ * 年费会员删除月费会员产品,月费会员删除年费会员产品
842
+ */
843
+
844
+ interface UseAutoRemovePlusMemberInCartProps {
845
+ profile: any;
846
+ cart?: NormalizedCart;
847
+ memberSetting: PlusMemberSettingsMetafields;
848
+ }
849
+ /**
850
+ * 自动移除购物车中的会员产品
851
+ *
852
+ * @param props - Hook 参数
853
+ * @param props.memberSetting - Plus Member 配置
854
+ * @param props.isMonthlyPlus - 用户是否是月费会员
855
+ * @param props.isAnnualPlus - 用户是否是年费会员
856
+ *
857
+ * @example
858
+ * ```tsx
859
+ * const { profile } = useProfile()
860
+ *
861
+ * useAutoRemovePlusMemberInCart({
862
+ * cart,
863
+ * profile,
864
+ * })
865
+ * ```
866
+ */
867
+ declare function useAutoRemovePlusMemberInCart({ cart, profile, memberSetting, }: UseAutoRemovePlusMemberInCartProps): void;
868
+
869
+ /**
870
+ * useHasPlusMemberInCart Hook
871
+ * 判断购物车中是否包含年费会员或月费会员产品
872
+ */
873
+
874
+ interface UseHasPlusMemberInCartProps {
875
+ /** Plus Member 配置 */
876
+ memberSetting?: PlusMemberSettingsMetafields;
877
+ /** 购物车数据 */
878
+ cart?: NormalizedCart;
879
+ }
880
+ interface HasPlusMemberInCartResult {
881
+ /** 购物车中是否有任何会员产品 */
882
+ hasPlusMember: boolean;
883
+ /** 购物车中是否有月费会员产品 */
884
+ hasMonthlyPlus: boolean;
885
+ /** 购物车中是否有年费会员产品 */
886
+ hasAnnualPlus: boolean;
887
+ /** 月费会员产品的 line item */
888
+ monthlyPlusItem?: {
889
+ id: string;
890
+ quantity: number;
891
+ handle?: string;
892
+ sku?: string;
893
+ };
894
+ /** 年费会员产品的 line item */
895
+ annualPlusItem?: {
896
+ id: string;
897
+ quantity: number;
898
+ handle?: string;
899
+ sku?: string;
900
+ };
901
+ }
902
+ /**
903
+ * 判断购物车中是否包含年费会员或月费会员产品
904
+ *
905
+ * @param props - Hook 参数
906
+ * @param props.metafields - Plus Member 配置
907
+ * @returns 会员产品信息
908
+ *
909
+ * @example
910
+ * ```tsx
911
+ * const {
912
+ * hasPlusMember,
913
+ * hasMonthlyPlus,
914
+ * hasAnnualPlus,
915
+ * monthlyPlusItem,
916
+ * annualPlusItem,
917
+ * } = useHasPlusMemberInCart({
918
+ * memberSetting: plusMemberSettings,
919
+ * })
920
+ *
921
+ * if (hasPlusMember) {
922
+ * console.log('购物车中有会员产品')
923
+ * }
924
+ * ```
925
+ */
926
+ declare function useHasPlusMemberInCart({ memberSetting, cart, }: UseHasPlusMemberInCartProps): HasPlusMemberInCartResult;
927
+
928
+ /**
929
+ * 返回需要添加到购物车的 Plus Member 产品
930
+ *
931
+ * 该 hook 会根据用户选择的会员模式和购物车现有状态,
932
+ * 返回需要添加的会员产品。如果不需要添加会员产品,则返回 undefined。
933
+ *
934
+ * @param props - Hook 参数
935
+ * @param props.cart - 购物车数据
936
+ * @returns Plus Member 产品对象或 undefined
937
+ *
938
+ * @example
939
+ * ```tsx
940
+ * const plusMemberProduct = useAddPlusMemberProductsToCart({
941
+ * cart,
942
+ * })
943
+ *
944
+ * // plusMemberProduct 格式:
945
+ * // {
946
+ * // product: NormalizedProduct,
947
+ * // variant: NormalizedProductVariant
948
+ * // }
949
+ * // 或 undefined (当不需要添加会员产品时)
950
+ * ```
951
+ */
952
+ declare function useAddPlusMemberProductsToCart({ cart, profile, }: {
953
+ cart: NormalizedCart;
954
+ profile?: any;
955
+ }): {
956
+ product: _anker_in_shopify_sdk.NormalizedProduct;
957
+ variant: _anker_in_shopify_sdk.NormalizedProductVariant;
958
+ } | undefined;
959
+
960
+ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
961
+ variant: TVariant;
962
+ product: TProduct;
963
+ memberSetting: PlusMemberSettingsMetafields;
964
+ initialSelectedPlusMemberMode?: DeliveryPlusType;
965
+ profile?: TProfile;
966
+ locale?: string;
967
+ }
968
+ /**
969
+ * Plus Member Provider Component
970
+ *
971
+ * Provides Plus Member context and state management to child components.
972
+ *
973
+ * @param variant - Product variant
974
+ * @param product - Product
975
+ * @param metafields - Plus member settings from metafields
976
+ * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
977
+ * @param profile - User profile
978
+ * @param locale - Locale code
979
+ * @param children - Child components
980
+ *
981
+ * @example
982
+ * ```tsx
983
+ * <PlusMemberProvider
984
+ * variant={variant}
985
+ * product={product}
986
+ * memberSetting={memberSetting}
987
+ * profile={profile}
988
+ * locale={locale}
989
+ * >
990
+ * <YourComponent />
991
+ * </PlusMemberProvider>
992
+ * ```
993
+ */
994
+ 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;
995
+
996
+ declare const getReferralAttributes: () => {
997
+ key: string;
998
+ value: string;
999
+ }[];
1000
+ declare const useCartAttributes: ({ profile, customer, cart, memberSetting, }: {
1001
+ profile: any;
1002
+ customer: any;
1003
+ cart?: NormalizedCart;
1004
+ memberSetting?: PlusMemberSettingsMetafields;
1005
+ }) => {
1006
+ attributes: Array<{
1007
+ key: string;
1008
+ value: any;
1009
+ }>;
1010
+ };
1011
+
1012
+ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
1013
+ cart?: NormalizedCart;
1014
+ cartItem: NormalizedLineItem;
1015
+ config: {
1016
+ handle: Record<string, {
1017
+ min: number;
1018
+ max: number;
1019
+ }>;
1020
+ sku: Record<string, {
1021
+ min: number;
1022
+ max: number;
1023
+ }>;
1024
+ };
1025
+ }) => {
1026
+ min: number;
1027
+ max: number;
1028
+ };
1029
+
1030
+ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
1031
+ cart?: NormalizedCart;
1032
+ mutateCart: (cart: NormalizedCart | undefined) => void;
1033
+ isCartLoading: boolean;
1034
+ setLoadingState: React.Dispatch<React.SetStateAction<any>>;
1035
+ metafieldIdentifiers?: {
1036
+ variant: HasMetafieldsIdentifier[];
1037
+ product: HasMetafieldsIdentifier[];
1038
+ };
1039
+ }) => void;
1040
+
1041
+ declare enum PriceDiscountType {
1042
+ PERCENTAGE = 1,// 百分比折扣
1043
+ FIXED_AMOUNT = 2
1044
+ }
1045
+ declare enum PriceBasePriceType {
1046
+ MIN_DISCOUNTED_PRICE = 1,// 最低折扣价
1047
+ MIN_TOTAL_PRICE = 2
1048
+ }
1049
+ type PriceDiscountConfig = {
1050
+ rule_id: number;
1051
+ rule_type: number;
1052
+ discount_type: PriceDiscountType;
1053
+ discount_value: number;
1054
+ base_price_type: PriceBasePriceType;
1055
+ applicable_products: Array<{
1056
+ product_id: string;
1057
+ variant_id?: string;
1058
+ }>;
1059
+ };
1060
+
1061
+ declare const currencyCodeMapping: Record<string, string>;
1062
+ declare const defaultSWRMutationConfiguration: SWRMutationConfiguration<any, any, any, any, any> & {
1063
+ throwOnError?: boolean;
1064
+ };
1065
+ declare const CUSTOMER_ATTRIBUTE_KEY = "_discounts_function_env";
1066
+ declare const CUSTOMER_SCRIPT_GIFT_KEY = "_giveaway_gradient_gifts";
1067
+ declare const CODE_AMOUNT_KEY = "_sku_code_money";
1068
+ declare const SCRIPT_CODE_AMOUNT_KEY = "_code_money";
1069
+ declare const MAIN_PRODUCT_CODE: string[];
1070
+
1071
+ /**
1072
+ * Normalize AddToCartLineItem[] to NormalizedLineItem[] format
1073
+ * This is used to calculate gifts from lines before they are added to cart
1074
+ */
1075
+ declare function normalizeAddToCartLines(lines: AddToCartLineItem[]): NormalizedLineItem[];
1076
+ /**
1077
+ * Create a mock cart structure from AddToCartLineItem[]
1078
+ * This is useful for calculating gifts before actual cart operations
1079
+ */
1080
+ declare function createMockCartFromLines(lines: AddToCartLineItem[], existingCart?: any): any;
1081
+
1082
+ declare const getQuery: () => Record<string, string>;
1083
+ declare function atobID(id: string): string | undefined;
1084
+ declare function btoaID(id: string, type?: 'ProductVariant' | 'Product'): string;
1085
+
1086
+ declare const getMatchedMainProductSubTotal: (cartData: any, variant_list: AutoFreeGiftMainProduct["variant_id_list"], main_product: AutoFreeGiftMainProduct) => any;
1087
+ declare const safeParse: (str: string) => any;
1088
+ declare const getDiscountEnvAttributeValue: (attributes?: {
1089
+ key: string;
1090
+ value: string;
1091
+ }[]) => any;
1092
+ declare const checkAttributesUpdateNeeded: (oldAttributes: NormalizedAttribute[], newAttributes: NormalizedAttribute[], customAttributesNeedRemove: {
1093
+ key: string;
1094
+ }[]) => boolean;
1095
+ declare function preCheck(rule_conditions: RuleCondition[], userTags: string[], currentDealsTypes: string[]): boolean;
1096
+ declare const formatScriptAutoFreeGift: ({ scriptAutoFreeGiftResult, gradient_gifts, locale, }: {
1097
+ scriptAutoFreeGiftResult: UseScriptAutoFreeGiftResult;
1098
+ gradient_gifts: any;
1099
+ locale: string;
1100
+ }) => any[];
1101
+ declare const formatFunctionAutoFreeGift: ({ qualifyingGift, giftProductsResult, locale, }: {
1102
+ locale: string;
1103
+ qualifyingGift?: FormattedGift | null;
1104
+ giftProductsResult?: NormalizedProduct[] | [];
1105
+ }) => any[];
1106
+
1107
+ interface UseProductOptions extends SWRConfiguration<NormalizedProduct | undefined> {
1108
+ handle?: string;
1109
+ metafieldIdentifiers?: Array<{
1110
+ namespace: string;
1111
+ key: string;
1112
+ }>;
1113
+ }
1114
+ /**
1115
+ * Hook to fetch a single product by handle
1116
+ *
1117
+ * @param options - Hook options including handle and SWR configuration
1118
+ * @returns SWR response with product data
1119
+ *
1120
+ * @example
1121
+ * ```typescript
1122
+ * function ProductPage() {
1123
+ * const { data: product, error, isLoading } = useProduct({
1124
+ * handle: 'my-product'
1125
+ * })
1126
+ *
1127
+ * if (isLoading) return <div>Loading...</div>
1128
+ * if (error) return <div>Error loading product</div>
1129
+ * if (!product) return <div>Product not found</div>
1130
+ *
1131
+ * return (
1132
+ * <div>
1133
+ * <h1>{product.title}</h1>
1134
+ * <p>{product.description}</p>
1135
+ * <p>${product.price.amount}</p>
1136
+ * </div>
1137
+ * )
1138
+ * }
1139
+ * ```
1140
+ */
1141
+ 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>;
1142
+
1143
+ interface UseAllProductsOptions extends SWRConfiguration<NormalizedProduct[]> {
1144
+ first?: number;
1145
+ query?: string;
1146
+ sortKey?: 'TITLE' | 'PRODUCT_TYPE' | 'VENDOR' | 'UPDATED_AT' | 'CREATED_AT' | 'BEST_SELLING' | 'PRICE' | 'RELEVANCE';
1147
+ reverse?: boolean;
1148
+ metafieldIdentifiers?: Array<{
1149
+ namespace: string;
1150
+ key: string;
1151
+ }>;
1152
+ }
1153
+ /**
1154
+ * Hook to fetch all products
1155
+ *
1156
+ * This hook automatically handles pagination and fetches all products.
1157
+ * Use with caution on stores with many products.
1158
+ *
1159
+ * @param options - Hook options including query parameters and SWR configuration
1160
+ * @returns SWR response with products array
1161
+ *
1162
+ * @example
1163
+ * ```typescript
1164
+ * function ProductList() {
1165
+ * const { data: products, error, isLoading } = useAllProducts({
1166
+ * sortKey: 'TITLE',
1167
+ * reverse: false
1168
+ * })
1169
+ *
1170
+ * if (isLoading) return <div>Loading...</div>
1171
+ * if (error) return <div>Error loading products</div>
1172
+ *
1173
+ * return (
1174
+ * <div>
1175
+ * {products?.map(product => (
1176
+ * <div key={product.id}>
1177
+ * <h2>{product.title}</h2>
1178
+ * <p>${product.price.amount}</p>
1179
+ * </div>
1180
+ * ))}
1181
+ * </div>
1182
+ * )
1183
+ * }
1184
+ * ```
1185
+ */
1186
+ 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>;
1187
+
1188
+ interface UseProductsByHandlesOptions extends SWRConfiguration<NormalizedProduct[]> {
1189
+ handles?: string[];
1190
+ metafieldIdentifiers?: {
1191
+ product: HasMetafieldsIdentifier[];
1192
+ variant: HasMetafieldsIdentifier[];
1193
+ };
1194
+ }
1195
+ /**
1196
+ * Hook to fetch multiple products by their handles
1197
+ *
1198
+ * @param options - Hook options including handles array and SWR configuration
1199
+ * @returns SWR response with products array
1200
+ *
1201
+ * @example
1202
+ * ```typescript
1203
+ * function FeaturedProducts() {
1204
+ * const { data: products, error, isLoading } = useProductsByHandles({
1205
+ * handles: ['product-1', 'product-2', 'product-3']
1206
+ * })
1207
+ *
1208
+ * if (isLoading) return <div>Loading...</div>
1209
+ * if (error) return <div>Error loading products</div>
1210
+ *
1211
+ * return (
1212
+ * <div>
1213
+ * {products?.map(product => (
1214
+ * <div key={product.id}>
1215
+ * <h2>{product.title}</h2>
1216
+ * <p>${product.price.amount}</p>
1217
+ * </div>
1218
+ * ))}
1219
+ * </div>
1220
+ * )
1221
+ * }
1222
+ * ```
1223
+ */
1224
+ 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>;
1225
+
1226
+ /**
1227
+ * useVariant Hook
1228
+ *
1229
+ * Client-side hook to get the selected variant based on selected options
1230
+ */
1231
+
1232
+ type Options = Record<string, string>;
1233
+ /**
1234
+ * Hook to manage variant selection based on selected options
1235
+ *
1236
+ * @param product - The product object
1237
+ * @param selectedOptions - Currently selected options { Color: 'Red', Size: 'M' }
1238
+ * @returns The matching variant
1239
+ *
1240
+ * @example
1241
+ * ```typescript
1242
+ * function ProductDetail() {
1243
+ * const { data: product } = useProduct({ handle: 'my-product' })
1244
+ * const [selectedOptions, setSelectedOptions] = useState({ Color: 'Red', Size: 'M' })
1245
+ * const variant = useVariant({ product, selectedOptions })
1246
+ *
1247
+ * return (
1248
+ * <div>
1249
+ * <h1>{product.title}</h1>
1250
+ * <p>Selected: {variant.title}</p>
1251
+ * <p>Price: ${variant.price.amount}</p>
1252
+ * <p>Available: {variant.availableForSale ? 'Yes' : 'No'}</p>
1253
+ * </div>
1254
+ * )
1255
+ * }
1256
+ * ```
1257
+ */
1258
+ declare function useVariant({ product, selectedOptions, }: {
1259
+ product?: NormalizedProduct;
1260
+ selectedOptions: Options;
1261
+ }): NormalizedProductVariant | undefined;
1262
+
1263
+ /**
1264
+ * usePrice Hook
1265
+ *
1266
+ * Client-side hook to format price for display
1267
+ */
1268
+ interface UsePriceOptions {
1269
+ amount: number;
1270
+ baseAmount?: number;
1271
+ currencyCode: string;
1272
+ soldOutDescription?: string;
1273
+ maximumFractionDigits?: number;
1274
+ minimumFractionDigits?: number;
1275
+ removeTrailingZeros?: boolean;
1276
+ }
1277
+ interface UsePriceResult {
1278
+ price: string;
1279
+ basePrice?: string;
1280
+ free: boolean;
1281
+ }
1282
+ /**
1283
+ * Hook to format price for display
1284
+ *
1285
+ * @param options - Price formatting options
1286
+ * @returns Formatted price object
1287
+ *
1288
+ * @example
1289
+ * ```typescript
1290
+ * function ProductPrice({ variant }) {
1291
+ * const { price, basePrice, free } = usePrice({
1292
+ * amount: variant.price.amount,
1293
+ * baseAmount: variant.compareAtPrice?.amount,
1294
+ * currencyCode: variant.price.currencyCode
1295
+ * })
1296
+ *
1297
+ * return (
1298
+ * <div>
1299
+ * {free ? (
1300
+ * <span>Free</span>
1301
+ * ) : (
1302
+ * <>
1303
+ * <span className="price">{price}</span>
1304
+ * {basePrice && <span className="original">{basePrice}</span>}
1305
+ * </>
1306
+ * )}
1307
+ * </div>
1308
+ * )
1309
+ * }
1310
+ * ```
1311
+ */
1312
+ declare function usePrice({ amount, baseAmount, currencyCode, soldOutDescription, maximumFractionDigits, minimumFractionDigits, removeTrailingZeros, }: UsePriceOptions): UsePriceResult;
1313
+
1314
+ /**
1315
+ * useSelectedOptions Hook
1316
+ *
1317
+ * Client-side hook to manage selected product options
1318
+ */
1319
+
1320
+ type SelectedOptionsResult = [Options, Dispatch<SetStateAction<Options>>];
1321
+ /**
1322
+ * Hook to manage selected product options based on URL query or SKU
1323
+ *
1324
+ * @param product - The product object
1325
+ * @param sku - Optional SKU to match variant
1326
+ * @returns Tuple of [options, setOptions]
1327
+ *
1328
+ * @example
1329
+ * ```typescript
1330
+ * function ProductDetail() {
1331
+ * const { data: product } = useProduct({ handle: 'my-product' })
1332
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1333
+ * const variant = useVariant({ product, selectedOptions })
1334
+ *
1335
+ * const handleOptionChange = (name: string, value: string) => {
1336
+ * setSelectedOptions(prev => ({ ...prev, [name]: value }))
1337
+ * }
1338
+ *
1339
+ * return (
1340
+ * <div>
1341
+ * {product?.options.map(option => (
1342
+ * <select
1343
+ * key={option.id}
1344
+ * value={selectedOptions[option.name] || ''}
1345
+ * onChange={(e) => handleOptionChange(option.name, e.target.value)}
1346
+ * >
1347
+ * {option.values.map(value => (
1348
+ * <option key={value.label} value={value.label}>
1349
+ * {value.label}
1350
+ * </option>
1351
+ * ))}
1352
+ * </select>
1353
+ * ))}
1354
+ * <p>Selected: {variant?.title}</p>
1355
+ * </div>
1356
+ * )
1357
+ * }
1358
+ * ```
1359
+ */
1360
+ declare function useSelectedOptions(product?: NormalizedProduct, sku?: string): SelectedOptionsResult;
1361
+
1362
+ /**
1363
+ * useProductUrl Hook
1364
+ *
1365
+ * Hook to generate product URLs with variant query params
1366
+ * Requires routerAdapter to be configured in ShopifyProvider
1367
+ */
1368
+
1369
+ /**
1370
+ * Hook to generate product URLs
1371
+ *
1372
+ * @param otherQuery - Additional query parameters to include
1373
+ * @returns Function to generate product URL
1374
+ *
1375
+ * @example
1376
+ * ```typescript
1377
+ * function ProductCard({ product, variant }) {
1378
+ * const getProductUrl = useProductUrl()
1379
+ *
1380
+ * const url = getProductUrl({ product, variant })
1381
+ *
1382
+ * return (
1383
+ * <a href={url}>
1384
+ * <h2>{product.title}</h2>
1385
+ * <p>{variant.title}</p>
1386
+ * </a>
1387
+ * )
1388
+ * }
1389
+ * ```
1390
+ *
1391
+ * @example With additional query params
1392
+ * ```typescript
1393
+ * function ProductCard({ product, variant }) {
1394
+ * const getProductUrl = useProductUrl({ utm_source: 'email' })
1395
+ *
1396
+ * const url = getProductUrl({ product, variant })
1397
+ * // URL will include: ?variant=123&utm_source=email
1398
+ *
1399
+ * return <a href={url}>{product.title}</a>
1400
+ * }
1401
+ * ```
1402
+ */
1403
+ declare function useProductUrl(otherQuery?: Record<string, string>): ({ product, variant }: {
1404
+ product?: NormalizedProduct;
1405
+ variant?: NormalizedProductVariant;
1406
+ }) => string;
1407
+
1408
+ /**
1409
+ * useUpdateVariantQuery Hook
1410
+ *
1411
+ * Hook to automatically update URL query string when variant changes
1412
+ */
1413
+
1414
+ /**
1415
+ * Hook to update URL query string when variant changes
1416
+ *
1417
+ * This hook automatically updates the browser URL with the selected variant ID
1418
+ * without causing a page reload. Useful for shareable URLs and browser history.
1419
+ *
1420
+ * @param variant - The selected variant
1421
+ *
1422
+ * @example
1423
+ * ```typescript
1424
+ * function ProductDetail() {
1425
+ * const { data: product } = useProduct({ handle: 'my-product' })
1426
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1427
+ * const variant = useVariant({ product, selectedOptions })
1428
+ *
1429
+ * // Automatically updates URL when variant changes
1430
+ * useUpdateVariantQuery(variant)
1431
+ *
1432
+ * return (
1433
+ * <div>
1434
+ * <h1>{product?.title}</h1>
1435
+ * <p>Current variant: {variant?.title}</p>
1436
+ * {/* URL will be: /products/my-product?variant=123456 *\/}
1437
+ * </div>
1438
+ * )
1439
+ * }
1440
+ * ```
1441
+ */
1442
+ declare function useUpdateVariantQuery(variant?: NormalizedProductVariant): void;
1443
+
1444
+ /**
1445
+ * useVariantMedia Hook
1446
+ *
1447
+ * Hook to get media (images and videos) for the selected variant
1448
+ */
1449
+
1450
+ type ImageMedia = Media & {
1451
+ mediaContentType: 'IMAGE';
1452
+ };
1453
+ type VideoMedia = Media & {
1454
+ mediaContentType: 'VIDEO' | 'EXTERNAL_VIDEO';
1455
+ };
1456
+ interface VariantMedia {
1457
+ productList: ImageMedia[];
1458
+ sceneList: ImageMedia[];
1459
+ videoList: VideoMedia[];
1460
+ }
1461
+ /**
1462
+ * Hook to get media for the selected variant
1463
+ *
1464
+ * @param product - The product object
1465
+ * @param variant - The selected variant
1466
+ * @returns Object with productList (first image), sceneList (other images), videoList
1467
+ *
1468
+ * @example
1469
+ * ```typescript
1470
+ * function ProductGallery() {
1471
+ * const { data: product } = useProduct({ handle: 'my-product' })
1472
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1473
+ * const variant = useVariant({ product, selectedOptions })
1474
+ * const { productList, sceneList, videoList } = useVariantMedia({ product, variant })
1475
+ *
1476
+ * return (
1477
+ * <div>
1478
+ * {/* Main product image *\/}
1479
+ * {productList.map(media => (
1480
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1481
+ * ))}
1482
+ *
1483
+ * {/* Scene/detail images *\/}
1484
+ * {sceneList.map(media => (
1485
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1486
+ * ))}
1487
+ *
1488
+ * {/* Videos *\/}
1489
+ * {videoList.map(media => (
1490
+ * <video key={media.id} src={media.sources?.[0]?.url} controls />
1491
+ * ))}
1492
+ * </div>
1493
+ * )
1494
+ * }
1495
+ * ```
1496
+ */
1497
+ declare function useVariantMedia({ product, variant, }: {
1498
+ product?: NormalizedProduct;
1499
+ variant?: NormalizedProductVariant;
1500
+ }): VariantMedia;
1501
+
1502
+ interface UseCollectionOptions extends SWRConfiguration<NormalizedCollection | undefined> {
1503
+ handle?: string;
1504
+ metafieldIdentifiers?: Array<{
1505
+ namespace: string;
1506
+ key: string;
1507
+ }>;
1508
+ }
1509
+ 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>;
1510
+
1511
+ interface UseAllCollectionsOptions extends SWRConfiguration<NormalizedCollection[]> {
1512
+ first?: number;
1513
+ query?: string;
1514
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1515
+ reverse?: boolean;
1516
+ metafieldIdentifiers?: Array<{
1517
+ namespace: string;
1518
+ key: string;
1519
+ }>;
1520
+ }
1521
+ 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>;
1522
+
1523
+ interface UseCollectionsOptions extends SWRConfiguration<CollectionsConnection> {
1524
+ first?: number;
1525
+ after?: string;
1526
+ query?: string;
1527
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1528
+ reverse?: boolean;
1529
+ metafieldIdentifiers?: Array<{
1530
+ namespace: string;
1531
+ key: string;
1532
+ }>;
1533
+ }
1534
+ 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>;
1535
+
1536
+ interface UseBlogOptions extends SWRConfiguration<NormalizedBlog | undefined> {
1537
+ handle?: string;
1538
+ metafieldIdentifiers?: Array<{
1539
+ namespace: string;
1540
+ key: string;
1541
+ }>;
1542
+ }
1543
+ 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>;
1544
+
1545
+ interface UseAllBlogsOptions extends SWRConfiguration<NormalizedBlog[]> {
1546
+ first?: number;
1547
+ query?: string;
1548
+ metafieldIdentifiers?: Array<{
1549
+ namespace: string;
1550
+ key: string;
1551
+ }>;
1552
+ }
1553
+ 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>;
1554
+
1555
+ interface UseArticleOptions extends SWRConfiguration<NormalizedArticle | undefined> {
1556
+ blogHandle?: string;
1557
+ articleHandle?: string;
1558
+ metafieldIdentifiers?: Array<{
1559
+ namespace: string;
1560
+ key: string;
1561
+ }>;
1562
+ }
1563
+ 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>;
1564
+
1565
+ interface UseArticlesOptions extends SWRConfiguration<NormalizedArticle[]> {
1566
+ first?: number;
1567
+ query?: string;
1568
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1569
+ reverse?: boolean;
1570
+ metafieldIdentifiers?: Array<{
1571
+ namespace: string;
1572
+ key: string;
1573
+ }>;
1574
+ }
1575
+ 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>;
1576
+
1577
+ interface UseArticlesInBlogOptions extends SWRConfiguration<NormalizedArticle[]> {
1578
+ blogHandle?: string;
1579
+ first?: number;
1580
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1581
+ reverse?: boolean;
1582
+ metafieldIdentifiers?: Array<{
1583
+ namespace: string;
1584
+ key: string;
1585
+ }>;
1586
+ }
1587
+ 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>;
1588
+
1589
+ type SearchResultType = 'ARTICLE' | 'PAGE' | 'PRODUCT';
1590
+ interface SearchResultItem {
1591
+ type: SearchResultType;
1592
+ id?: string;
1593
+ handle?: string;
1594
+ title?: string;
1595
+ description?: string;
1596
+ url?: string;
1597
+ image?: {
1598
+ url: string;
1599
+ altText?: string;
1600
+ };
1601
+ }
1602
+ interface SearchResult {
1603
+ items: SearchResultItem[];
1604
+ totalCount: number;
1605
+ pageInfo?: {
1606
+ hasNextPage: boolean;
1607
+ endCursor?: string;
1608
+ };
1609
+ }
1610
+ interface UseSearchOptions extends SWRConfiguration<SearchResult | undefined> {
1611
+ query?: string;
1612
+ first?: number;
1613
+ types?: SearchResultType[];
1614
+ productFilters?: any[];
1615
+ }
1616
+ 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>;
1617
+
1618
+ interface SiteInfo {
1619
+ name: string;
1620
+ description?: string;
1621
+ primaryDomain: {
1622
+ url: string;
1623
+ host: string;
1624
+ };
1625
+ brand?: {
1626
+ logo?: {
1627
+ image?: {
1628
+ url: string;
1629
+ };
1630
+ };
1631
+ colors?: {
1632
+ primary?: string;
1633
+ secondary?: string;
1634
+ };
1635
+ };
1636
+ metafields?: Record<string, any>;
1637
+ }
1638
+ interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
1639
+ metafieldIdentifiers?: Array<{
1640
+ namespace: string;
1641
+ key: string;
1642
+ }>;
1643
+ }
1644
+ 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>;
1645
+
1646
+ /**
1647
+ * useIntersection Hook
1648
+ *
1649
+ * Observes element visibility using IntersectionObserver API
1650
+ */
1651
+
1652
+ interface UseIntersectionOptions {
1653
+ /** Callback function when element becomes visible */
1654
+ callback: () => void;
1655
+ /** Only trigger callback once (default: false) */
1656
+ once?: boolean;
1657
+ /** Root element for intersection (default: viewport) */
1658
+ root?: Element | null;
1659
+ /** Margin around root (default: '0px') */
1660
+ rootMargin?: string;
1661
+ /** Visibility threshold 0-1 (default: 0.8) */
1662
+ threshold?: number;
1663
+ }
1664
+ /**
1665
+ * Hook to observe element visibility with IntersectionObserver
1666
+ *
1667
+ * Triggers a callback when the target element becomes visible in the viewport
1668
+ *
1669
+ * @param targetRef - React ref to the target element
1670
+ * @param options - Intersection observer options
1671
+ *
1672
+ * @example
1673
+ * ```typescript
1674
+ * function LazyImage() {
1675
+ * const imageRef = useRef<HTMLImageElement>(null)
1676
+ * const [loaded, setLoaded] = useState(false)
1677
+ *
1678
+ * useIntersection(imageRef, {
1679
+ * callback: () => setLoaded(true),
1680
+ * once: true,
1681
+ * threshold: 0.5
1682
+ * })
1683
+ *
1684
+ * return (
1685
+ * <img
1686
+ * ref={imageRef}
1687
+ * src={loaded ? actualSrc : placeholderSrc}
1688
+ * alt="Lazy loaded"
1689
+ * />
1690
+ * )
1691
+ * }
1692
+ * ```
1693
+ */
1694
+ declare function useIntersection(targetRef: RefObject<Element> | undefined, options: UseIntersectionOptions): void;
1695
+
1696
+ /**
1697
+ * useExposure Hook
1698
+ *
1699
+ * Tracks element exposure (visibility + duration) for analytics/tracking
1700
+ */
1701
+
1702
+ interface UseExposureOptions {
1703
+ /** Visibility threshold 0-1 (default: 0.5, meaning 50% visible) */
1704
+ threshold?: number;
1705
+ /** Duration in milliseconds element must be visible (default: 2000ms) */
1706
+ duration?: number;
1707
+ /** Only trigger callback once (default: true) */
1708
+ once?: boolean;
1709
+ /** Callback when element has been exposed for the required duration */
1710
+ onExposure: () => void;
1711
+ }
1712
+ /**
1713
+ * Hook to track element exposure (visibility + duration threshold)
1714
+ *
1715
+ * Useful for tracking ad impressions, product views, or any analytics
1716
+ * that require an element to be visible for a certain duration
1717
+ *
1718
+ * @param targetRef - React ref to the target element
1719
+ * @param options - Exposure tracking options
1720
+ * @returns Current visibility state
1721
+ *
1722
+ * @example
1723
+ * ```typescript
1724
+ * function ProductCard({ product }) {
1725
+ * const cardRef = useRef<HTMLDivElement>(null)
1726
+ *
1727
+ * const isVisible = useExposure(cardRef, {
1728
+ * threshold: 0.5, // 50% visible
1729
+ * duration: 2000, // 2 seconds
1730
+ * once: true, // Only track once
1731
+ * onExposure: () => {
1732
+ * // Track product impression
1733
+ * analytics.track('Product Viewed', {
1734
+ * productId: product.id,
1735
+ * productName: product.title
1736
+ * })
1737
+ * }
1738
+ * })
1739
+ *
1740
+ * return (
1741
+ * <div ref={cardRef}>
1742
+ * {product.title}
1743
+ * {isVisible && <div className="viewing-indicator" />}
1744
+ * </div>
1745
+ * )
1746
+ * }
1747
+ * ```
1748
+ */
1749
+ declare function useExposure(targetRef: RefObject<Element>, options: UseExposureOptions): boolean;
1750
+
1751
+ /**
1752
+ * useGeoLocation Hook
1753
+ *
1754
+ * Fetches and caches user's geographic location
1755
+ */
1756
+
1757
+ interface GeoLocationData {
1758
+ /** Geographic information */
1759
+ geo: {
1760
+ /** Country information */
1761
+ country?: {
1762
+ /** Country code (e.g., 'US', 'GB') */
1763
+ code?: string;
1764
+ /** Country name */
1765
+ name?: string;
1766
+ };
1767
+ /** Region/state information */
1768
+ region?: {
1769
+ code?: string;
1770
+ name?: string;
1771
+ };
1772
+ /** City name */
1773
+ city?: string;
1774
+ /** Coordinates */
1775
+ latitude?: number;
1776
+ longitude?: number;
1777
+ /** Timezone */
1778
+ timezone?: string;
1779
+ };
1780
+ /** Suggested locale based on location */
1781
+ suggestLocale?: string;
1782
+ }
1783
+ interface LocaleMapping {
1784
+ /** Countries that should map to EU locale */
1785
+ euCountries?: string[];
1786
+ /** Countries that should map to DE locale */
1787
+ deCountries?: string[];
1788
+ /** Countries that should map to AU locale */
1789
+ auCountries?: string[];
1790
+ /** Countries that should map to AE-EN locale */
1791
+ aeEnCountries?: string[];
1792
+ /** Custom country to locale mapping */
1793
+ customMapping?: Record<string, string>;
1794
+ }
1795
+ interface UseGeoLocationOptions extends SWRConfiguration<GeoLocationData | undefined> {
1796
+ /** API endpoint for fetching geo data (default: '/geolocation') */
1797
+ endpoint?: string;
1798
+ /** Cache key for localStorage (default: 'geoLocation') */
1799
+ cacheKey?: string;
1800
+ /** Cache duration in milliseconds (default: 24 hours) */
1801
+ cacheDuration?: number;
1802
+ /** Locale mapping configuration */
1803
+ localeMapping?: LocaleMapping;
1804
+ /** Enable automatic caching (default: true) */
1805
+ enableCache?: boolean;
1806
+ }
1807
+ /**
1808
+ * Hook to fetch and cache user's geographic location
1809
+ *
1810
+ * Fetches geo data from an API endpoint and caches it in localStorage
1811
+ * Automatically determines suggested locale based on country
1812
+ *
1813
+ * @param options - Geo location options
1814
+ * @returns SWR response with geo location data
1815
+ *
1816
+ * @example
1817
+ * ```typescript
1818
+ * function LocaleSwitcher() {
1819
+ * const { data: geoData, error, isLoading } = useGeoLocation({
1820
+ * endpoint: '/api/geolocation',
1821
+ * localeMapping: {
1822
+ * euCountries: ['FR', 'DE', 'IT', 'ES'],
1823
+ * auCountries: ['AU', 'NZ']
1824
+ * }
1825
+ * })
1826
+ *
1827
+ * if (isLoading) return <div>Loading...</div>
1828
+ * if (error) return <div>Error loading location</div>
1829
+ *
1830
+ * return (
1831
+ * <div>
1832
+ * <p>Country: {geoData?.geo.country?.code}</p>
1833
+ * <p>Suggested Locale: {geoData?.suggestLocale}</p>
1834
+ * </div>
1835
+ * )
1836
+ * }
1837
+ * ```
1838
+ *
1839
+ * @example
1840
+ * ```typescript
1841
+ * // With custom locale mapping
1842
+ * const { data } = useGeoLocation({
1843
+ * localeMapping: {
1844
+ * customMapping: {
1845
+ * 'JP': 'ja',
1846
+ * 'CN': 'zh-cn',
1847
+ * 'TW': 'zh-tw'
1848
+ * }
1849
+ * }
1850
+ * })
1851
+ * ```
1852
+ */
1853
+ declare function useGeoLocation(options?: UseGeoLocationOptions): ReturnType<typeof swr__default<GeoLocationData | undefined>>;
1854
+ /**
1855
+ * Get cached geo location data without fetching
1856
+ *
1857
+ * @param cacheKey - Cache key (default: 'geoLocation')
1858
+ * @returns Cached geo data or undefined
1859
+ *
1860
+ * @example
1861
+ * ```typescript
1862
+ * const cachedGeo = getCachedGeoLocation()
1863
+ * if (cachedGeo) {
1864
+ * console.log('Country:', cachedGeo.geo.country?.code)
1865
+ * }
1866
+ * ```
1867
+ */
1868
+ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | undefined;
1869
+ /**
1870
+ * Clear cached geo location data
1871
+ *
1872
+ * @param cacheKey - Cache key (default: 'geoLocation')
1873
+ *
1874
+ * @example
1875
+ * ```typescript
1876
+ * clearGeoLocationCache()
1877
+ * ```
1878
+ */
1879
+ declare function clearGeoLocationCache(cacheKey?: string): void;
1880
+
1881
+ export { type AddCartLinesInput, AddToCartLineItem, type ApplyCartCodesInput, type AutoFreeGift, type AutoFreeGiftConfig, type AutoFreeGiftItem, type AutoFreeGiftList, type AutoFreeGiftMainProduct, type BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, type CartLineInput, 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 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 SearchResultItem, 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, atobID, btoaID, 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 };