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

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,1879 @@
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
+ };
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: any;
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
+
1084
+ declare const getMatchedMainProductSubTotal: (cartData: any, variant_list: AutoFreeGiftMainProduct["variant_id_list"], main_product: AutoFreeGiftMainProduct) => any;
1085
+ declare const safeParse: (str: string) => any;
1086
+ declare const getDiscountEnvAttributeValue: (attributes?: {
1087
+ key: string;
1088
+ value: string;
1089
+ }[]) => any;
1090
+ declare const checkAttributesUpdateNeeded: (oldAttributes: NormalizedAttribute[], newAttributes: NormalizedAttribute[], customAttributesNeedRemove: {
1091
+ key: string;
1092
+ }[]) => boolean;
1093
+ declare function preCheck(rule_conditions: RuleCondition[], userTags: string[], currentDealsTypes: string[]): boolean;
1094
+ declare const formatScriptAutoFreeGift: ({ scriptAutoFreeGiftResult, gradient_gifts, locale, }: {
1095
+ scriptAutoFreeGiftResult: UseScriptAutoFreeGiftResult;
1096
+ gradient_gifts: any;
1097
+ locale: string;
1098
+ }) => any[];
1099
+ declare const formatFunctionAutoFreeGift: ({ qualifyingGift, giftProductsResult, locale, }: {
1100
+ locale: string;
1101
+ qualifyingGift?: FormattedGift | null;
1102
+ giftProductsResult?: NormalizedProduct[] | [];
1103
+ }) => any[];
1104
+
1105
+ interface UseProductOptions extends SWRConfiguration<NormalizedProduct | undefined> {
1106
+ handle?: string;
1107
+ metafieldIdentifiers?: Array<{
1108
+ namespace: string;
1109
+ key: string;
1110
+ }>;
1111
+ }
1112
+ /**
1113
+ * Hook to fetch a single product by handle
1114
+ *
1115
+ * @param options - Hook options including handle and SWR configuration
1116
+ * @returns SWR response with product data
1117
+ *
1118
+ * @example
1119
+ * ```typescript
1120
+ * function ProductPage() {
1121
+ * const { data: product, error, isLoading } = useProduct({
1122
+ * handle: 'my-product'
1123
+ * })
1124
+ *
1125
+ * if (isLoading) return <div>Loading...</div>
1126
+ * if (error) return <div>Error loading product</div>
1127
+ * if (!product) return <div>Product not found</div>
1128
+ *
1129
+ * return (
1130
+ * <div>
1131
+ * <h1>{product.title}</h1>
1132
+ * <p>{product.description}</p>
1133
+ * <p>${product.price.amount}</p>
1134
+ * </div>
1135
+ * )
1136
+ * }
1137
+ * ```
1138
+ */
1139
+ 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>;
1140
+
1141
+ interface UseAllProductsOptions extends SWRConfiguration<NormalizedProduct[]> {
1142
+ first?: number;
1143
+ query?: string;
1144
+ sortKey?: 'TITLE' | 'PRODUCT_TYPE' | 'VENDOR' | 'UPDATED_AT' | 'CREATED_AT' | 'BEST_SELLING' | 'PRICE' | 'RELEVANCE';
1145
+ reverse?: boolean;
1146
+ metafieldIdentifiers?: Array<{
1147
+ namespace: string;
1148
+ key: string;
1149
+ }>;
1150
+ }
1151
+ /**
1152
+ * Hook to fetch all products
1153
+ *
1154
+ * This hook automatically handles pagination and fetches all products.
1155
+ * Use with caution on stores with many products.
1156
+ *
1157
+ * @param options - Hook options including query parameters and SWR configuration
1158
+ * @returns SWR response with products array
1159
+ *
1160
+ * @example
1161
+ * ```typescript
1162
+ * function ProductList() {
1163
+ * const { data: products, error, isLoading } = useAllProducts({
1164
+ * sortKey: 'TITLE',
1165
+ * reverse: false
1166
+ * })
1167
+ *
1168
+ * if (isLoading) return <div>Loading...</div>
1169
+ * if (error) return <div>Error loading products</div>
1170
+ *
1171
+ * return (
1172
+ * <div>
1173
+ * {products?.map(product => (
1174
+ * <div key={product.id}>
1175
+ * <h2>{product.title}</h2>
1176
+ * <p>${product.price.amount}</p>
1177
+ * </div>
1178
+ * ))}
1179
+ * </div>
1180
+ * )
1181
+ * }
1182
+ * ```
1183
+ */
1184
+ 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>;
1185
+
1186
+ interface UseProductsByHandlesOptions extends SWRConfiguration<NormalizedProduct[]> {
1187
+ handles?: string[];
1188
+ metafieldIdentifiers?: {
1189
+ product: HasMetafieldsIdentifier[];
1190
+ variant: HasMetafieldsIdentifier[];
1191
+ };
1192
+ }
1193
+ /**
1194
+ * Hook to fetch multiple products by their handles
1195
+ *
1196
+ * @param options - Hook options including handles array and SWR configuration
1197
+ * @returns SWR response with products array
1198
+ *
1199
+ * @example
1200
+ * ```typescript
1201
+ * function FeaturedProducts() {
1202
+ * const { data: products, error, isLoading } = useProductsByHandles({
1203
+ * handles: ['product-1', 'product-2', 'product-3']
1204
+ * })
1205
+ *
1206
+ * if (isLoading) return <div>Loading...</div>
1207
+ * if (error) return <div>Error loading products</div>
1208
+ *
1209
+ * return (
1210
+ * <div>
1211
+ * {products?.map(product => (
1212
+ * <div key={product.id}>
1213
+ * <h2>{product.title}</h2>
1214
+ * <p>${product.price.amount}</p>
1215
+ * </div>
1216
+ * ))}
1217
+ * </div>
1218
+ * )
1219
+ * }
1220
+ * ```
1221
+ */
1222
+ 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>;
1223
+
1224
+ /**
1225
+ * useVariant Hook
1226
+ *
1227
+ * Client-side hook to get the selected variant based on selected options
1228
+ */
1229
+
1230
+ type Options = Record<string, string>;
1231
+ /**
1232
+ * Hook to manage variant selection based on selected options
1233
+ *
1234
+ * @param product - The product object
1235
+ * @param selectedOptions - Currently selected options { Color: 'Red', Size: 'M' }
1236
+ * @returns The matching variant
1237
+ *
1238
+ * @example
1239
+ * ```typescript
1240
+ * function ProductDetail() {
1241
+ * const { data: product } = useProduct({ handle: 'my-product' })
1242
+ * const [selectedOptions, setSelectedOptions] = useState({ Color: 'Red', Size: 'M' })
1243
+ * const variant = useVariant({ product, selectedOptions })
1244
+ *
1245
+ * return (
1246
+ * <div>
1247
+ * <h1>{product.title}</h1>
1248
+ * <p>Selected: {variant.title}</p>
1249
+ * <p>Price: ${variant.price.amount}</p>
1250
+ * <p>Available: {variant.availableForSale ? 'Yes' : 'No'}</p>
1251
+ * </div>
1252
+ * )
1253
+ * }
1254
+ * ```
1255
+ */
1256
+ declare function useVariant({ product, selectedOptions, }: {
1257
+ product?: NormalizedProduct;
1258
+ selectedOptions: Options;
1259
+ }): NormalizedProductVariant | undefined;
1260
+
1261
+ /**
1262
+ * usePrice Hook
1263
+ *
1264
+ * Client-side hook to format price for display
1265
+ */
1266
+ interface UsePriceOptions {
1267
+ amount: number;
1268
+ baseAmount?: number;
1269
+ currencyCode: string;
1270
+ soldOutDescription?: string;
1271
+ maximumFractionDigits?: number;
1272
+ minimumFractionDigits?: number;
1273
+ removeTrailingZeros?: boolean;
1274
+ }
1275
+ interface UsePriceResult {
1276
+ price: string;
1277
+ basePrice?: string;
1278
+ free: boolean;
1279
+ }
1280
+ /**
1281
+ * Hook to format price for display
1282
+ *
1283
+ * @param options - Price formatting options
1284
+ * @returns Formatted price object
1285
+ *
1286
+ * @example
1287
+ * ```typescript
1288
+ * function ProductPrice({ variant }) {
1289
+ * const { price, basePrice, free } = usePrice({
1290
+ * amount: variant.price.amount,
1291
+ * baseAmount: variant.compareAtPrice?.amount,
1292
+ * currencyCode: variant.price.currencyCode
1293
+ * })
1294
+ *
1295
+ * return (
1296
+ * <div>
1297
+ * {free ? (
1298
+ * <span>Free</span>
1299
+ * ) : (
1300
+ * <>
1301
+ * <span className="price">{price}</span>
1302
+ * {basePrice && <span className="original">{basePrice}</span>}
1303
+ * </>
1304
+ * )}
1305
+ * </div>
1306
+ * )
1307
+ * }
1308
+ * ```
1309
+ */
1310
+ declare function usePrice({ amount, baseAmount, currencyCode, soldOutDescription, maximumFractionDigits, minimumFractionDigits, removeTrailingZeros, }: UsePriceOptions): UsePriceResult;
1311
+
1312
+ /**
1313
+ * useSelectedOptions Hook
1314
+ *
1315
+ * Client-side hook to manage selected product options
1316
+ */
1317
+
1318
+ type SelectedOptionsResult = [Options, Dispatch<SetStateAction<Options>>];
1319
+ /**
1320
+ * Hook to manage selected product options based on URL query or SKU
1321
+ *
1322
+ * @param product - The product object
1323
+ * @param sku - Optional SKU to match variant
1324
+ * @returns Tuple of [options, setOptions]
1325
+ *
1326
+ * @example
1327
+ * ```typescript
1328
+ * function ProductDetail() {
1329
+ * const { data: product } = useProduct({ handle: 'my-product' })
1330
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1331
+ * const variant = useVariant({ product, selectedOptions })
1332
+ *
1333
+ * const handleOptionChange = (name: string, value: string) => {
1334
+ * setSelectedOptions(prev => ({ ...prev, [name]: value }))
1335
+ * }
1336
+ *
1337
+ * return (
1338
+ * <div>
1339
+ * {product?.options.map(option => (
1340
+ * <select
1341
+ * key={option.id}
1342
+ * value={selectedOptions[option.name] || ''}
1343
+ * onChange={(e) => handleOptionChange(option.name, e.target.value)}
1344
+ * >
1345
+ * {option.values.map(value => (
1346
+ * <option key={value.label} value={value.label}>
1347
+ * {value.label}
1348
+ * </option>
1349
+ * ))}
1350
+ * </select>
1351
+ * ))}
1352
+ * <p>Selected: {variant?.title}</p>
1353
+ * </div>
1354
+ * )
1355
+ * }
1356
+ * ```
1357
+ */
1358
+ declare function useSelectedOptions(product?: NormalizedProduct, sku?: string): SelectedOptionsResult;
1359
+
1360
+ /**
1361
+ * useProductUrl Hook
1362
+ *
1363
+ * Hook to generate product URLs with variant query params
1364
+ * Requires routerAdapter to be configured in ShopifyProvider
1365
+ */
1366
+
1367
+ /**
1368
+ * Hook to generate product URLs
1369
+ *
1370
+ * @param otherQuery - Additional query parameters to include
1371
+ * @returns Function to generate product URL
1372
+ *
1373
+ * @example
1374
+ * ```typescript
1375
+ * function ProductCard({ product, variant }) {
1376
+ * const getProductUrl = useProductUrl()
1377
+ *
1378
+ * const url = getProductUrl({ product, variant })
1379
+ *
1380
+ * return (
1381
+ * <a href={url}>
1382
+ * <h2>{product.title}</h2>
1383
+ * <p>{variant.title}</p>
1384
+ * </a>
1385
+ * )
1386
+ * }
1387
+ * ```
1388
+ *
1389
+ * @example With additional query params
1390
+ * ```typescript
1391
+ * function ProductCard({ product, variant }) {
1392
+ * const getProductUrl = useProductUrl({ utm_source: 'email' })
1393
+ *
1394
+ * const url = getProductUrl({ product, variant })
1395
+ * // URL will include: ?variant=123&utm_source=email
1396
+ *
1397
+ * return <a href={url}>{product.title}</a>
1398
+ * }
1399
+ * ```
1400
+ */
1401
+ declare function useProductUrl(otherQuery?: Record<string, string>): ({ product, variant }: {
1402
+ product?: NormalizedProduct;
1403
+ variant?: NormalizedProductVariant;
1404
+ }) => string;
1405
+
1406
+ /**
1407
+ * useUpdateVariantQuery Hook
1408
+ *
1409
+ * Hook to automatically update URL query string when variant changes
1410
+ */
1411
+
1412
+ /**
1413
+ * Hook to update URL query string when variant changes
1414
+ *
1415
+ * This hook automatically updates the browser URL with the selected variant ID
1416
+ * without causing a page reload. Useful for shareable URLs and browser history.
1417
+ *
1418
+ * @param variant - The selected variant
1419
+ *
1420
+ * @example
1421
+ * ```typescript
1422
+ * function ProductDetail() {
1423
+ * const { data: product } = useProduct({ handle: 'my-product' })
1424
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1425
+ * const variant = useVariant({ product, selectedOptions })
1426
+ *
1427
+ * // Automatically updates URL when variant changes
1428
+ * useUpdateVariantQuery(variant)
1429
+ *
1430
+ * return (
1431
+ * <div>
1432
+ * <h1>{product?.title}</h1>
1433
+ * <p>Current variant: {variant?.title}</p>
1434
+ * {/* URL will be: /products/my-product?variant=123456 *\/}
1435
+ * </div>
1436
+ * )
1437
+ * }
1438
+ * ```
1439
+ */
1440
+ declare function useUpdateVariantQuery(variant?: NormalizedProductVariant): void;
1441
+
1442
+ /**
1443
+ * useVariantMedia Hook
1444
+ *
1445
+ * Hook to get media (images and videos) for the selected variant
1446
+ */
1447
+
1448
+ type ImageMedia = Media & {
1449
+ mediaContentType: 'IMAGE';
1450
+ };
1451
+ type VideoMedia = Media & {
1452
+ mediaContentType: 'VIDEO' | 'EXTERNAL_VIDEO';
1453
+ };
1454
+ interface VariantMedia {
1455
+ productList: ImageMedia[];
1456
+ sceneList: ImageMedia[];
1457
+ videoList: VideoMedia[];
1458
+ }
1459
+ /**
1460
+ * Hook to get media for the selected variant
1461
+ *
1462
+ * @param product - The product object
1463
+ * @param variant - The selected variant
1464
+ * @returns Object with productList (first image), sceneList (other images), videoList
1465
+ *
1466
+ * @example
1467
+ * ```typescript
1468
+ * function ProductGallery() {
1469
+ * const { data: product } = useProduct({ handle: 'my-product' })
1470
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1471
+ * const variant = useVariant({ product, selectedOptions })
1472
+ * const { productList, sceneList, videoList } = useVariantMedia({ product, variant })
1473
+ *
1474
+ * return (
1475
+ * <div>
1476
+ * {/* Main product image *\/}
1477
+ * {productList.map(media => (
1478
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1479
+ * ))}
1480
+ *
1481
+ * {/* Scene/detail images *\/}
1482
+ * {sceneList.map(media => (
1483
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1484
+ * ))}
1485
+ *
1486
+ * {/* Videos *\/}
1487
+ * {videoList.map(media => (
1488
+ * <video key={media.id} src={media.sources?.[0]?.url} controls />
1489
+ * ))}
1490
+ * </div>
1491
+ * )
1492
+ * }
1493
+ * ```
1494
+ */
1495
+ declare function useVariantMedia({ product, variant, }: {
1496
+ product?: NormalizedProduct;
1497
+ variant?: NormalizedProductVariant;
1498
+ }): VariantMedia;
1499
+
1500
+ interface UseCollectionOptions extends SWRConfiguration<NormalizedCollection | undefined> {
1501
+ handle?: string;
1502
+ metafieldIdentifiers?: Array<{
1503
+ namespace: string;
1504
+ key: string;
1505
+ }>;
1506
+ }
1507
+ 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>;
1508
+
1509
+ interface UseAllCollectionsOptions extends SWRConfiguration<NormalizedCollection[]> {
1510
+ first?: number;
1511
+ query?: string;
1512
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1513
+ reverse?: boolean;
1514
+ metafieldIdentifiers?: Array<{
1515
+ namespace: string;
1516
+ key: string;
1517
+ }>;
1518
+ }
1519
+ 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>;
1520
+
1521
+ interface UseCollectionsOptions extends SWRConfiguration<CollectionsConnection> {
1522
+ first?: number;
1523
+ after?: string;
1524
+ query?: string;
1525
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1526
+ reverse?: boolean;
1527
+ metafieldIdentifiers?: Array<{
1528
+ namespace: string;
1529
+ key: string;
1530
+ }>;
1531
+ }
1532
+ 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>;
1533
+
1534
+ interface UseBlogOptions extends SWRConfiguration<NormalizedBlog | undefined> {
1535
+ handle?: string;
1536
+ metafieldIdentifiers?: Array<{
1537
+ namespace: string;
1538
+ key: string;
1539
+ }>;
1540
+ }
1541
+ 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>;
1542
+
1543
+ interface UseAllBlogsOptions extends SWRConfiguration<NormalizedBlog[]> {
1544
+ first?: number;
1545
+ query?: string;
1546
+ metafieldIdentifiers?: Array<{
1547
+ namespace: string;
1548
+ key: string;
1549
+ }>;
1550
+ }
1551
+ 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>;
1552
+
1553
+ interface UseArticleOptions extends SWRConfiguration<NormalizedArticle | undefined> {
1554
+ blogHandle?: string;
1555
+ articleHandle?: string;
1556
+ metafieldIdentifiers?: Array<{
1557
+ namespace: string;
1558
+ key: string;
1559
+ }>;
1560
+ }
1561
+ 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>;
1562
+
1563
+ interface UseArticlesOptions extends SWRConfiguration<NormalizedArticle[]> {
1564
+ first?: number;
1565
+ query?: string;
1566
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1567
+ reverse?: boolean;
1568
+ metafieldIdentifiers?: Array<{
1569
+ namespace: string;
1570
+ key: string;
1571
+ }>;
1572
+ }
1573
+ 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>;
1574
+
1575
+ interface UseArticlesInBlogOptions extends SWRConfiguration<NormalizedArticle[]> {
1576
+ blogHandle?: string;
1577
+ first?: number;
1578
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1579
+ reverse?: boolean;
1580
+ metafieldIdentifiers?: Array<{
1581
+ namespace: string;
1582
+ key: string;
1583
+ }>;
1584
+ }
1585
+ 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>;
1586
+
1587
+ type SearchResultType = 'ARTICLE' | 'PAGE' | 'PRODUCT';
1588
+ interface NormalizedSearchResultItem {
1589
+ type: SearchResultType;
1590
+ id?: string;
1591
+ handle?: string;
1592
+ title?: string;
1593
+ description?: string;
1594
+ url?: string;
1595
+ image?: {
1596
+ url: string;
1597
+ altText?: string;
1598
+ };
1599
+ }
1600
+ interface SearchResult {
1601
+ items: NormalizedSearchResultItem[];
1602
+ totalCount: number;
1603
+ pageInfo?: {
1604
+ hasNextPage: boolean;
1605
+ endCursor?: string;
1606
+ };
1607
+ }
1608
+ interface UseSearchOptions extends SWRConfiguration<SearchResult | undefined> {
1609
+ query?: string;
1610
+ first?: number;
1611
+ types?: SearchResultType[];
1612
+ productFilters?: any[];
1613
+ }
1614
+ 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>;
1615
+
1616
+ interface SiteInfo {
1617
+ name: string;
1618
+ description?: string;
1619
+ primaryDomain: {
1620
+ url: string;
1621
+ host: string;
1622
+ };
1623
+ brand?: {
1624
+ logo?: {
1625
+ image?: {
1626
+ url: string;
1627
+ };
1628
+ };
1629
+ colors?: {
1630
+ primary?: string;
1631
+ secondary?: string;
1632
+ };
1633
+ };
1634
+ metafields?: Record<string, any>;
1635
+ }
1636
+ interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
1637
+ metafieldIdentifiers?: Array<{
1638
+ namespace: string;
1639
+ key: string;
1640
+ }>;
1641
+ }
1642
+ 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>;
1643
+
1644
+ /**
1645
+ * useIntersection Hook
1646
+ *
1647
+ * Observes element visibility using IntersectionObserver API
1648
+ */
1649
+
1650
+ interface UseIntersectionOptions {
1651
+ /** Callback function when element becomes visible */
1652
+ callback: () => void;
1653
+ /** Only trigger callback once (default: false) */
1654
+ once?: boolean;
1655
+ /** Root element for intersection (default: viewport) */
1656
+ root?: Element | null;
1657
+ /** Margin around root (default: '0px') */
1658
+ rootMargin?: string;
1659
+ /** Visibility threshold 0-1 (default: 0.8) */
1660
+ threshold?: number;
1661
+ }
1662
+ /**
1663
+ * Hook to observe element visibility with IntersectionObserver
1664
+ *
1665
+ * Triggers a callback when the target element becomes visible in the viewport
1666
+ *
1667
+ * @param targetRef - React ref to the target element
1668
+ * @param options - Intersection observer options
1669
+ *
1670
+ * @example
1671
+ * ```typescript
1672
+ * function LazyImage() {
1673
+ * const imageRef = useRef<HTMLImageElement>(null)
1674
+ * const [loaded, setLoaded] = useState(false)
1675
+ *
1676
+ * useIntersection(imageRef, {
1677
+ * callback: () => setLoaded(true),
1678
+ * once: true,
1679
+ * threshold: 0.5
1680
+ * })
1681
+ *
1682
+ * return (
1683
+ * <img
1684
+ * ref={imageRef}
1685
+ * src={loaded ? actualSrc : placeholderSrc}
1686
+ * alt="Lazy loaded"
1687
+ * />
1688
+ * )
1689
+ * }
1690
+ * ```
1691
+ */
1692
+ declare function useIntersection(targetRef: RefObject<Element> | undefined, options: UseIntersectionOptions): void;
1693
+
1694
+ /**
1695
+ * useExposure Hook
1696
+ *
1697
+ * Tracks element exposure (visibility + duration) for analytics/tracking
1698
+ */
1699
+
1700
+ interface UseExposureOptions {
1701
+ /** Visibility threshold 0-1 (default: 0.5, meaning 50% visible) */
1702
+ threshold?: number;
1703
+ /** Duration in milliseconds element must be visible (default: 2000ms) */
1704
+ duration?: number;
1705
+ /** Only trigger callback once (default: true) */
1706
+ once?: boolean;
1707
+ /** Callback when element has been exposed for the required duration */
1708
+ onExposure: () => void;
1709
+ }
1710
+ /**
1711
+ * Hook to track element exposure (visibility + duration threshold)
1712
+ *
1713
+ * Useful for tracking ad impressions, product views, or any analytics
1714
+ * that require an element to be visible for a certain duration
1715
+ *
1716
+ * @param targetRef - React ref to the target element
1717
+ * @param options - Exposure tracking options
1718
+ * @returns Current visibility state
1719
+ *
1720
+ * @example
1721
+ * ```typescript
1722
+ * function ProductCard({ product }) {
1723
+ * const cardRef = useRef<HTMLDivElement>(null)
1724
+ *
1725
+ * const isVisible = useExposure(cardRef, {
1726
+ * threshold: 0.5, // 50% visible
1727
+ * duration: 2000, // 2 seconds
1728
+ * once: true, // Only track once
1729
+ * onExposure: () => {
1730
+ * // Track product impression
1731
+ * analytics.track('Product Viewed', {
1732
+ * productId: product.id,
1733
+ * productName: product.title
1734
+ * })
1735
+ * }
1736
+ * })
1737
+ *
1738
+ * return (
1739
+ * <div ref={cardRef}>
1740
+ * {product.title}
1741
+ * {isVisible && <div className="viewing-indicator" />}
1742
+ * </div>
1743
+ * )
1744
+ * }
1745
+ * ```
1746
+ */
1747
+ declare function useExposure(targetRef: RefObject<Element>, options: UseExposureOptions): boolean;
1748
+
1749
+ /**
1750
+ * useGeoLocation Hook
1751
+ *
1752
+ * Fetches and caches user's geographic location
1753
+ */
1754
+
1755
+ interface GeoLocationData {
1756
+ /** Geographic information */
1757
+ geo: {
1758
+ /** Country information */
1759
+ country?: {
1760
+ /** Country code (e.g., 'US', 'GB') */
1761
+ code?: string;
1762
+ /** Country name */
1763
+ name?: string;
1764
+ };
1765
+ /** Region/state information */
1766
+ region?: {
1767
+ code?: string;
1768
+ name?: string;
1769
+ };
1770
+ /** City name */
1771
+ city?: string;
1772
+ /** Coordinates */
1773
+ latitude?: number;
1774
+ longitude?: number;
1775
+ /** Timezone */
1776
+ timezone?: string;
1777
+ };
1778
+ /** Suggested locale based on location */
1779
+ suggestLocale?: string;
1780
+ }
1781
+ interface LocaleMapping {
1782
+ /** Countries that should map to EU locale */
1783
+ euCountries?: string[];
1784
+ /** Countries that should map to DE locale */
1785
+ deCountries?: string[];
1786
+ /** Countries that should map to AU locale */
1787
+ auCountries?: string[];
1788
+ /** Countries that should map to AE-EN locale */
1789
+ aeEnCountries?: string[];
1790
+ /** Custom country to locale mapping */
1791
+ customMapping?: Record<string, string>;
1792
+ }
1793
+ interface UseGeoLocationOptions extends SWRConfiguration<GeoLocationData | undefined> {
1794
+ /** API endpoint for fetching geo data (default: '/geolocation') */
1795
+ endpoint?: string;
1796
+ /** Cache key for localStorage (default: 'geoLocation') */
1797
+ cacheKey?: string;
1798
+ /** Cache duration in milliseconds (default: 24 hours) */
1799
+ cacheDuration?: number;
1800
+ /** Locale mapping configuration */
1801
+ localeMapping?: LocaleMapping;
1802
+ /** Enable automatic caching (default: true) */
1803
+ enableCache?: boolean;
1804
+ }
1805
+ /**
1806
+ * Hook to fetch and cache user's geographic location
1807
+ *
1808
+ * Fetches geo data from an API endpoint and caches it in localStorage
1809
+ * Automatically determines suggested locale based on country
1810
+ *
1811
+ * @param options - Geo location options
1812
+ * @returns SWR response with geo location data
1813
+ *
1814
+ * @example
1815
+ * ```typescript
1816
+ * function LocaleSwitcher() {
1817
+ * const { data: geoData, error, isLoading } = useGeoLocation({
1818
+ * endpoint: '/api/geolocation',
1819
+ * localeMapping: {
1820
+ * euCountries: ['FR', 'DE', 'IT', 'ES'],
1821
+ * auCountries: ['AU', 'NZ']
1822
+ * }
1823
+ * })
1824
+ *
1825
+ * if (isLoading) return <div>Loading...</div>
1826
+ * if (error) return <div>Error loading location</div>
1827
+ *
1828
+ * return (
1829
+ * <div>
1830
+ * <p>Country: {geoData?.geo.country?.code}</p>
1831
+ * <p>Suggested Locale: {geoData?.suggestLocale}</p>
1832
+ * </div>
1833
+ * )
1834
+ * }
1835
+ * ```
1836
+ *
1837
+ * @example
1838
+ * ```typescript
1839
+ * // With custom locale mapping
1840
+ * const { data } = useGeoLocation({
1841
+ * localeMapping: {
1842
+ * customMapping: {
1843
+ * 'JP': 'ja',
1844
+ * 'CN': 'zh-cn',
1845
+ * 'TW': 'zh-tw'
1846
+ * }
1847
+ * }
1848
+ * })
1849
+ * ```
1850
+ */
1851
+ declare function useGeoLocation(options?: UseGeoLocationOptions): ReturnType<typeof swr__default<GeoLocationData | undefined>>;
1852
+ /**
1853
+ * Get cached geo location data without fetching
1854
+ *
1855
+ * @param cacheKey - Cache key (default: 'geoLocation')
1856
+ * @returns Cached geo data or undefined
1857
+ *
1858
+ * @example
1859
+ * ```typescript
1860
+ * const cachedGeo = getCachedGeoLocation()
1861
+ * if (cachedGeo) {
1862
+ * console.log('Country:', cachedGeo.geo.country?.code)
1863
+ * }
1864
+ * ```
1865
+ */
1866
+ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | undefined;
1867
+ /**
1868
+ * Clear cached geo location data
1869
+ *
1870
+ * @param cacheKey - Cache key (default: 'geoLocation')
1871
+ *
1872
+ * @example
1873
+ * ```typescript
1874
+ * clearGeoLocationCache()
1875
+ * ```
1876
+ */
1877
+ declare function clearGeoLocationCache(cacheKey?: string): void;
1878
+
1879
+ 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 };