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

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