@storepecker/storefront-core 2.6.3 → 2.9.0

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.
Files changed (49) hide show
  1. package/dist/api/index.cjs +90 -46
  2. package/dist/api/index.d.cts +99 -7
  3. package/dist/api/index.d.ts +99 -7
  4. package/dist/api/index.js +3 -3
  5. package/dist/buy-now-B1dkx82V.d.cts +197 -0
  6. package/dist/buy-now-BgKd5p4J.d.ts +197 -0
  7. package/dist/checkout/index.cjs +78 -31
  8. package/dist/checkout/index.d.cts +47 -9
  9. package/dist/checkout/index.d.ts +47 -9
  10. package/dist/checkout/index.js +64 -18
  11. package/dist/{chunk-GTV42PDK.cjs → chunk-57UU7IJ2.cjs} +1 -0
  12. package/dist/{chunk-ZQOESVVE.cjs → chunk-CIBMO44U.cjs} +26 -31
  13. package/dist/{chunk-5BT3MH4A.cjs → chunk-ETXIP5XE.cjs} +3 -3
  14. package/dist/{chunk-LZADKC4Y.cjs → chunk-H6FJYRO3.cjs} +55 -3
  15. package/dist/{chunk-ME6Z7TZW.js → chunk-KCLVR6G5.js} +45 -4
  16. package/dist/{chunk-LCMJYFHC.cjs → chunk-NQZ5GUOG.cjs} +0 -1
  17. package/dist/{chunk-4C4NTH6O.js → chunk-OOFYY6GR.js} +1 -0
  18. package/dist/{chunk-PGBYYKFQ.js → chunk-SU5LVRZD.js} +9 -14
  19. package/dist/{chunk-QSHOJ3NJ.cjs → chunk-TFWTQTWE.cjs} +40 -19
  20. package/dist/{chunk-H32TICAM.js → chunk-TH7OAMGC.js} +0 -1
  21. package/dist/{chunk-VYHAWRJR.js → chunk-UWW5YIHL.js} +39 -18
  22. package/dist/{chunk-TY5NK7NW.js → chunk-YMZZCVZ2.js} +1 -1
  23. package/dist/components/digital-product-download-modal.d.cts +1 -1
  24. package/dist/components/digital-product-download-modal.d.ts +1 -1
  25. package/dist/components/index.d.cts +2 -2
  26. package/dist/components/index.d.ts +2 -2
  27. package/dist/components/theme-data-initializer.d.cts +2 -2
  28. package/dist/components/theme-data-initializer.d.ts +2 -2
  29. package/dist/hooks/index.cjs +564 -29
  30. package/dist/hooks/index.d.cts +179 -2
  31. package/dist/hooks/index.d.ts +179 -2
  32. package/dist/hooks/index.js +541 -10
  33. package/dist/middleware/index.cjs +3 -3
  34. package/dist/middleware/index.js +1 -1
  35. package/dist/models/index.d.cts +2 -1
  36. package/dist/models/index.d.ts +2 -1
  37. package/dist/{orders-9_scVq_M.d.cts → orders-COKWr7K7.d.cts} +1 -0
  38. package/dist/{orders-C1XZr8tx.d.ts → orders-Cp8qNCrl.d.ts} +1 -0
  39. package/dist/{pixelEvents-D0sH22Er.d.ts → pixelEvents-2Tb-_fRP.d.ts} +2 -1
  40. package/dist/{pixelEvents-uiPHbiAQ.d.cts → pixelEvents-BJNH06rS.d.cts} +2 -1
  41. package/dist/store/index.cjs +9 -9
  42. package/dist/store/index.d.cts +9 -4
  43. package/dist/store/index.d.ts +9 -4
  44. package/dist/store/index.js +4 -4
  45. package/dist/utils/index.cjs +7 -7
  46. package/dist/utils/index.d.cts +4 -3
  47. package/dist/utils/index.d.ts +4 -3
  48. package/dist/utils/index.js +2 -2
  49. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import { A as Address } from '../address-DwBZHzbI.cjs';
2
2
  import * as React from 'react';
3
3
  import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-CyN2JQTw.cjs';
4
- import { O as Order } from '../orders-9_scVq_M.cjs';
4
+ import { O as Order } from '../orders-COKWr7K7.cjs';
5
5
  import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-CZtFWhxO.cjs';
6
6
  import { W as Wishlist } from '../wishlist-Cx9Vrszq.cjs';
7
+ import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-B1dkx82V.cjs';
7
8
  export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-DGbEn91-.cjs';
8
9
  import 'react-toastify';
9
10
  import 'formik';
@@ -99,6 +100,12 @@ interface UseCheckoutPaymentOptions {
99
100
  onStripeModalOpen?: (order: Order.OrderSummary) => void;
100
101
  onSuccess?: (order: Order.OrderSummary) => void;
101
102
  onFailure?: (order: Order.OrderSummary) => void;
103
+ /**
104
+ * Translate typed placement errors (invalid shipping option, stock shortage)
105
+ * into targeted UI — see `describePlacementError`. Return true when handled;
106
+ * anything else falls through to the failure modal.
107
+ */
108
+ onPlaceOrderError?: (error: unknown) => boolean | void;
102
109
  }
103
110
  interface UseCheckoutPaymentReturn {
104
111
  orderSummary: Order.OrderSummary | null;
@@ -118,6 +125,175 @@ interface UseCheckoutPaymentReturn {
118
125
  */
119
126
  declare function useCheckoutPayment(options: UseCheckoutPaymentOptions): UseCheckoutPaymentReturn;
120
127
 
128
+ /** Args every inline-checkout `placeOrder` accepts (buy-now and public alike). */
129
+ interface InlinePlaceOrderArgs {
130
+ isCod?: boolean;
131
+ phonepeRedirectUrl?: string;
132
+ stripeRedirectUrl?: string;
133
+ tabbyRedirectUrl?: string;
134
+ /** Required for guests — the collected contact + shipping address. */
135
+ guest?: Checkout.GuestContact;
136
+ }
137
+ interface UseInlineCheckoutPaymentOptions {
138
+ /** Whether the customer is logged in — drives the guest (`isPublic`) branch. */
139
+ isAuthenticated: boolean;
140
+ /** Places the order and returns it (from `useBuyNow` / `usePublicCheckout`). */
141
+ placeOrder: (args: InlinePlaceOrderArgs) => Promise<Order.OrderSummary | undefined>;
142
+ phonepeRedirectUrl: string;
143
+ stripeRedirectUrl?: string;
144
+ tabbyRedirectUrl?: string;
145
+ onRedirect: (url: string) => void;
146
+ onStripeModalOpen?: (order: Order.OrderSummary) => void;
147
+ onSuccess?: (order: Order.OrderSummary) => void;
148
+ onFailure?: (order: Order.OrderSummary) => void;
149
+ /**
150
+ * Called on confirmed success only (COD confirmed, Razorpay/Stripe-modal
151
+ * success) so the theme can drop the stashed selection or the local cart.
152
+ * Redirect gateways confirm on the return leg — clear there instead, or a
153
+ * customer who abandons the gateway loses their basket.
154
+ */
155
+ onClearItem?: () => void;
156
+ /** Required for guests — supplies the collected contact + shipping address. */
157
+ getGuestContact?: () => Checkout.GuestContact | undefined;
158
+ /**
159
+ * Translate typed placement errors (invalid shipping option, stock shortage,
160
+ * empty cart) into targeted UI — a toast, a shipping reset, a re-price —
161
+ * instead of the generic failure modal. Return true when the error was
162
+ * handled; anything else falls through to the failure modal.
163
+ */
164
+ onPlaceOrderError?: (error: unknown) => boolean | void;
165
+ }
166
+ interface UseInlineCheckoutPaymentReturn {
167
+ orderSummary: Order.OrderSummary | null;
168
+ isPlacingOrder: boolean;
169
+ isConfirmingPayment: boolean;
170
+ showSuccessModal: boolean;
171
+ showFailureModal: boolean;
172
+ setShowSuccessModal: (show: boolean) => void;
173
+ setShowFailureModal: (show: boolean) => void;
174
+ placeAndPay: (paymentMethod: string) => Promise<void>;
175
+ }
176
+ /**
177
+ * Places an inline (cartless or local-cart) order and routes the created order
178
+ * to the right payment gateway. Shared by Buy Now and public checkout.
179
+ *
180
+ * Unlike the cart flow it NEVER resets the server cart badge (`onCartReset` is a
181
+ * no-op): a buy-now purchase must leave the customer's cart untouched, and a
182
+ * guest has no server cart to reset. Guests place through the public endpoints,
183
+ * so `isPublic` is threaded into `processPayment` to reach the `public-*`
184
+ * success routes — the authenticated ones 401 without a JWT, and that failure
185
+ * would only surface *after* the customer has paid.
186
+ */
187
+ declare function useInlineCheckoutPayment(options: UseInlineCheckoutPaymentOptions): UseInlineCheckoutPaymentReturn;
188
+
189
+ /** sessionStorage key holding the Buy Now selection stashed by the product page. */
190
+ declare const BUY_NOW_PAYLOAD_KEY = "____bn_pl_";
191
+ /** What the product page stashes before navigating to the buy-now checkout. */
192
+ interface BuyNowItem {
193
+ variant_id: number;
194
+ quantity: number;
195
+ customization_inputs?: BuyNow.CustomizationInput[];
196
+ is_preorder?: boolean;
197
+ preorder_ship_days?: number;
198
+ }
199
+ interface BuyNowError {
200
+ code: string;
201
+ message: string;
202
+ }
203
+ interface UseBuyNowReturn {
204
+ item: BuyNowItem | null;
205
+ preview: BuyNow.PreviewResponse | null;
206
+ quantity: number;
207
+ couponCodes: string[] | undefined;
208
+ addressId: number | undefined;
209
+ guestAddress: BuyNow.GuestAddress | undefined;
210
+ shippingOptionId: number | undefined;
211
+ isLoading: boolean;
212
+ isRefreshing: boolean;
213
+ placingOrder: boolean;
214
+ notFound: boolean;
215
+ error: BuyNowError | null;
216
+ missingItems: {
217
+ [variantId: number]: number;
218
+ };
219
+ appliedCoupon: BuyNow.PreviewResponse["applied_coupons"] | null;
220
+ setQuantity: (value: number) => void;
221
+ setAddressId: (id?: number) => void;
222
+ setShippingOptionId: (id?: number) => void;
223
+ applyCoupon: (code: string) => void;
224
+ removeCoupon: () => void;
225
+ setGuestAddress: (address?: BuyNow.GuestAddress) => void;
226
+ refresh: () => void;
227
+ clearItem: () => void;
228
+ placeOrder: (args: InlinePlaceOrderArgs) => Promise<Order.OrderSummary | undefined>;
229
+ }
230
+ /**
231
+ * Owns all buy-now checkout data: the inline item, its live price preview, and
232
+ * the coupon/address/shipping selections that re-price it. It deliberately never
233
+ * reads or writes the customer's cart — pricing goes through the preview
234
+ * endpoint and placement through the buy-now / public-order endpoints.
235
+ *
236
+ * Works for both logged-in customers and guests:
237
+ * - logged-in → preview with `address_id`, place via `POST /customer/buy_now/`
238
+ * - guest → preview with an inline `address` (country/state/pincode), place
239
+ * via `POST /customer/public_order/` with `is_buy_now: true`
240
+ *
241
+ * For guests the first preview runs without an address (so the product + subtotal
242
+ * render immediately); tax/shipping appear once `setGuestAddress` is called with a
243
+ * complete destination.
244
+ *
245
+ * Navigation, toasts and payment orchestration are intentionally NOT here — the
246
+ * theme owns those (see `useInlineCheckoutPayment` for the placement + gateway flow).
247
+ */
248
+ declare function useBuyNow(isAuthenticated?: boolean): UseBuyNowReturn;
249
+
250
+ interface PublicCheckoutError {
251
+ code: string;
252
+ message: string;
253
+ }
254
+ interface UsePublicCheckoutReturn {
255
+ preview: PublicCheckout.PreviewResponse | null;
256
+ cartItems: Record<number, number>;
257
+ couponCodes: string[] | undefined;
258
+ guestAddress: Checkout.GuestAddress | undefined;
259
+ shippingOptionId: number | undefined;
260
+ isCod: boolean;
261
+ isCodEnabled: boolean;
262
+ codAmount: number;
263
+ isLoading: boolean;
264
+ isRefreshing: boolean;
265
+ placingOrder: boolean;
266
+ isEmpty: boolean;
267
+ error: PublicCheckoutError | null;
268
+ missingItems: {
269
+ [variantId: number]: number;
270
+ };
271
+ appliedCoupon: PublicCheckout.PreviewResponse["applied_coupons"] | null;
272
+ setGuestAddress: (address?: Checkout.GuestAddress) => void;
273
+ setShippingOptionId: (id?: number) => void;
274
+ setIsCod: (value: boolean) => void;
275
+ applyCoupon: (code: string) => void;
276
+ removeCoupon: () => void;
277
+ refresh: () => void;
278
+ clearCart: () => void;
279
+ placeOrder: (args: InlinePlaceOrderArgs) => Promise<Order.OrderSummary | undefined>;
280
+ }
281
+ /**
282
+ * Owns the guest checkout: reads the local cart, prices it live through the
283
+ * public preview endpoint, and places the order.
284
+ *
285
+ * Everything that affects the total — quantities, coupon, destination, shipping
286
+ * option and the COD toggle — is sent to the preview, never computed here. The
287
+ * endpoint guarantees its `total_amount` equals what placement will charge, so
288
+ * the page can show it as final; adding `cod_amount` or shipping locally would
289
+ * double-count and reintroduce the "total jumps after placing" bug.
290
+ *
291
+ * Also works for a logged-in customer on the same page (send the JWT; saved
292
+ * addresses and cached coupons then resolve server-side).
293
+ *
294
+ */
295
+ declare function usePublicCheckout(): UsePublicCheckoutReturn;
296
+
121
297
  interface UseCheckoutCouponOptions {
122
298
  onCartRefresh: () => void | Promise<void>;
123
299
  autoFetch?: boolean;
@@ -174,6 +350,7 @@ interface UseShopCheckoutOptions {
174
350
  onNavigateToCart?: () => void;
175
351
  /** Called when a toast/notification should be shown. */
176
352
  onToast?: (message: string, type?: "success" | "error") => void;
353
+ onPreorderRejected?: () => void;
177
354
  }
178
355
  interface UseShopCheckoutReturn {
179
356
  isWishlisted: boolean;
@@ -220,4 +397,4 @@ interface UseCouponReturn {
220
397
  }
221
398
  declare function useCoupon(options?: UseCouponOptions): UseCouponReturn;
222
399
 
223
- export { type PaginationMode, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, useAddress, useCart, useCheckoutCoupon, useCheckoutPayment, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useOrders, useProductDetailModal, useServiceFormModal, useShopCheckout, useUserDetails, useVariantSelector, useWishlist };
400
+ export { BUY_NOW_PAYLOAD_KEY, type BuyNowError, type BuyNowItem, type InlinePlaceOrderArgs, type PaginationMode, type PublicCheckoutError, type UseBuyNowReturn, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseInlineCheckoutPaymentOptions, type UseInlineCheckoutPaymentReturn, type UsePublicCheckoutReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, useAddress, useBuyNow, useCart, useCheckoutCoupon, useCheckoutPayment, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useInlineCheckoutPayment, useOrders, useProductDetailModal, usePublicCheckout, useServiceFormModal, useShopCheckout, useUserDetails, useVariantSelector, useWishlist };
@@ -1,9 +1,10 @@
1
1
  import { A as Address } from '../address-DwBZHzbI.js';
2
2
  import * as React from 'react';
3
3
  import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-BGIsIZdM.js';
4
- import { O as Order } from '../orders-C1XZr8tx.js';
4
+ import { O as Order } from '../orders-Cp8qNCrl.js';
5
5
  import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-CZtFWhxO.js';
6
6
  import { W as Wishlist } from '../wishlist-CRNbfFIx.js';
7
+ import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-BgKd5p4J.js';
7
8
  export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-cO3Au33k.js';
8
9
  import 'react-toastify';
9
10
  import 'formik';
@@ -99,6 +100,12 @@ interface UseCheckoutPaymentOptions {
99
100
  onStripeModalOpen?: (order: Order.OrderSummary) => void;
100
101
  onSuccess?: (order: Order.OrderSummary) => void;
101
102
  onFailure?: (order: Order.OrderSummary) => void;
103
+ /**
104
+ * Translate typed placement errors (invalid shipping option, stock shortage)
105
+ * into targeted UI — see `describePlacementError`. Return true when handled;
106
+ * anything else falls through to the failure modal.
107
+ */
108
+ onPlaceOrderError?: (error: unknown) => boolean | void;
102
109
  }
103
110
  interface UseCheckoutPaymentReturn {
104
111
  orderSummary: Order.OrderSummary | null;
@@ -118,6 +125,175 @@ interface UseCheckoutPaymentReturn {
118
125
  */
119
126
  declare function useCheckoutPayment(options: UseCheckoutPaymentOptions): UseCheckoutPaymentReturn;
120
127
 
128
+ /** Args every inline-checkout `placeOrder` accepts (buy-now and public alike). */
129
+ interface InlinePlaceOrderArgs {
130
+ isCod?: boolean;
131
+ phonepeRedirectUrl?: string;
132
+ stripeRedirectUrl?: string;
133
+ tabbyRedirectUrl?: string;
134
+ /** Required for guests — the collected contact + shipping address. */
135
+ guest?: Checkout.GuestContact;
136
+ }
137
+ interface UseInlineCheckoutPaymentOptions {
138
+ /** Whether the customer is logged in — drives the guest (`isPublic`) branch. */
139
+ isAuthenticated: boolean;
140
+ /** Places the order and returns it (from `useBuyNow` / `usePublicCheckout`). */
141
+ placeOrder: (args: InlinePlaceOrderArgs) => Promise<Order.OrderSummary | undefined>;
142
+ phonepeRedirectUrl: string;
143
+ stripeRedirectUrl?: string;
144
+ tabbyRedirectUrl?: string;
145
+ onRedirect: (url: string) => void;
146
+ onStripeModalOpen?: (order: Order.OrderSummary) => void;
147
+ onSuccess?: (order: Order.OrderSummary) => void;
148
+ onFailure?: (order: Order.OrderSummary) => void;
149
+ /**
150
+ * Called on confirmed success only (COD confirmed, Razorpay/Stripe-modal
151
+ * success) so the theme can drop the stashed selection or the local cart.
152
+ * Redirect gateways confirm on the return leg — clear there instead, or a
153
+ * customer who abandons the gateway loses their basket.
154
+ */
155
+ onClearItem?: () => void;
156
+ /** Required for guests — supplies the collected contact + shipping address. */
157
+ getGuestContact?: () => Checkout.GuestContact | undefined;
158
+ /**
159
+ * Translate typed placement errors (invalid shipping option, stock shortage,
160
+ * empty cart) into targeted UI — a toast, a shipping reset, a re-price —
161
+ * instead of the generic failure modal. Return true when the error was
162
+ * handled; anything else falls through to the failure modal.
163
+ */
164
+ onPlaceOrderError?: (error: unknown) => boolean | void;
165
+ }
166
+ interface UseInlineCheckoutPaymentReturn {
167
+ orderSummary: Order.OrderSummary | null;
168
+ isPlacingOrder: boolean;
169
+ isConfirmingPayment: boolean;
170
+ showSuccessModal: boolean;
171
+ showFailureModal: boolean;
172
+ setShowSuccessModal: (show: boolean) => void;
173
+ setShowFailureModal: (show: boolean) => void;
174
+ placeAndPay: (paymentMethod: string) => Promise<void>;
175
+ }
176
+ /**
177
+ * Places an inline (cartless or local-cart) order and routes the created order
178
+ * to the right payment gateway. Shared by Buy Now and public checkout.
179
+ *
180
+ * Unlike the cart flow it NEVER resets the server cart badge (`onCartReset` is a
181
+ * no-op): a buy-now purchase must leave the customer's cart untouched, and a
182
+ * guest has no server cart to reset. Guests place through the public endpoints,
183
+ * so `isPublic` is threaded into `processPayment` to reach the `public-*`
184
+ * success routes — the authenticated ones 401 without a JWT, and that failure
185
+ * would only surface *after* the customer has paid.
186
+ */
187
+ declare function useInlineCheckoutPayment(options: UseInlineCheckoutPaymentOptions): UseInlineCheckoutPaymentReturn;
188
+
189
+ /** sessionStorage key holding the Buy Now selection stashed by the product page. */
190
+ declare const BUY_NOW_PAYLOAD_KEY = "____bn_pl_";
191
+ /** What the product page stashes before navigating to the buy-now checkout. */
192
+ interface BuyNowItem {
193
+ variant_id: number;
194
+ quantity: number;
195
+ customization_inputs?: BuyNow.CustomizationInput[];
196
+ is_preorder?: boolean;
197
+ preorder_ship_days?: number;
198
+ }
199
+ interface BuyNowError {
200
+ code: string;
201
+ message: string;
202
+ }
203
+ interface UseBuyNowReturn {
204
+ item: BuyNowItem | null;
205
+ preview: BuyNow.PreviewResponse | null;
206
+ quantity: number;
207
+ couponCodes: string[] | undefined;
208
+ addressId: number | undefined;
209
+ guestAddress: BuyNow.GuestAddress | undefined;
210
+ shippingOptionId: number | undefined;
211
+ isLoading: boolean;
212
+ isRefreshing: boolean;
213
+ placingOrder: boolean;
214
+ notFound: boolean;
215
+ error: BuyNowError | null;
216
+ missingItems: {
217
+ [variantId: number]: number;
218
+ };
219
+ appliedCoupon: BuyNow.PreviewResponse["applied_coupons"] | null;
220
+ setQuantity: (value: number) => void;
221
+ setAddressId: (id?: number) => void;
222
+ setShippingOptionId: (id?: number) => void;
223
+ applyCoupon: (code: string) => void;
224
+ removeCoupon: () => void;
225
+ setGuestAddress: (address?: BuyNow.GuestAddress) => void;
226
+ refresh: () => void;
227
+ clearItem: () => void;
228
+ placeOrder: (args: InlinePlaceOrderArgs) => Promise<Order.OrderSummary | undefined>;
229
+ }
230
+ /**
231
+ * Owns all buy-now checkout data: the inline item, its live price preview, and
232
+ * the coupon/address/shipping selections that re-price it. It deliberately never
233
+ * reads or writes the customer's cart — pricing goes through the preview
234
+ * endpoint and placement through the buy-now / public-order endpoints.
235
+ *
236
+ * Works for both logged-in customers and guests:
237
+ * - logged-in → preview with `address_id`, place via `POST /customer/buy_now/`
238
+ * - guest → preview with an inline `address` (country/state/pincode), place
239
+ * via `POST /customer/public_order/` with `is_buy_now: true`
240
+ *
241
+ * For guests the first preview runs without an address (so the product + subtotal
242
+ * render immediately); tax/shipping appear once `setGuestAddress` is called with a
243
+ * complete destination.
244
+ *
245
+ * Navigation, toasts and payment orchestration are intentionally NOT here — the
246
+ * theme owns those (see `useInlineCheckoutPayment` for the placement + gateway flow).
247
+ */
248
+ declare function useBuyNow(isAuthenticated?: boolean): UseBuyNowReturn;
249
+
250
+ interface PublicCheckoutError {
251
+ code: string;
252
+ message: string;
253
+ }
254
+ interface UsePublicCheckoutReturn {
255
+ preview: PublicCheckout.PreviewResponse | null;
256
+ cartItems: Record<number, number>;
257
+ couponCodes: string[] | undefined;
258
+ guestAddress: Checkout.GuestAddress | undefined;
259
+ shippingOptionId: number | undefined;
260
+ isCod: boolean;
261
+ isCodEnabled: boolean;
262
+ codAmount: number;
263
+ isLoading: boolean;
264
+ isRefreshing: boolean;
265
+ placingOrder: boolean;
266
+ isEmpty: boolean;
267
+ error: PublicCheckoutError | null;
268
+ missingItems: {
269
+ [variantId: number]: number;
270
+ };
271
+ appliedCoupon: PublicCheckout.PreviewResponse["applied_coupons"] | null;
272
+ setGuestAddress: (address?: Checkout.GuestAddress) => void;
273
+ setShippingOptionId: (id?: number) => void;
274
+ setIsCod: (value: boolean) => void;
275
+ applyCoupon: (code: string) => void;
276
+ removeCoupon: () => void;
277
+ refresh: () => void;
278
+ clearCart: () => void;
279
+ placeOrder: (args: InlinePlaceOrderArgs) => Promise<Order.OrderSummary | undefined>;
280
+ }
281
+ /**
282
+ * Owns the guest checkout: reads the local cart, prices it live through the
283
+ * public preview endpoint, and places the order.
284
+ *
285
+ * Everything that affects the total — quantities, coupon, destination, shipping
286
+ * option and the COD toggle — is sent to the preview, never computed here. The
287
+ * endpoint guarantees its `total_amount` equals what placement will charge, so
288
+ * the page can show it as final; adding `cod_amount` or shipping locally would
289
+ * double-count and reintroduce the "total jumps after placing" bug.
290
+ *
291
+ * Also works for a logged-in customer on the same page (send the JWT; saved
292
+ * addresses and cached coupons then resolve server-side).
293
+ *
294
+ */
295
+ declare function usePublicCheckout(): UsePublicCheckoutReturn;
296
+
121
297
  interface UseCheckoutCouponOptions {
122
298
  onCartRefresh: () => void | Promise<void>;
123
299
  autoFetch?: boolean;
@@ -174,6 +350,7 @@ interface UseShopCheckoutOptions {
174
350
  onNavigateToCart?: () => void;
175
351
  /** Called when a toast/notification should be shown. */
176
352
  onToast?: (message: string, type?: "success" | "error") => void;
353
+ onPreorderRejected?: () => void;
177
354
  }
178
355
  interface UseShopCheckoutReturn {
179
356
  isWishlisted: boolean;
@@ -220,4 +397,4 @@ interface UseCouponReturn {
220
397
  }
221
398
  declare function useCoupon(options?: UseCouponOptions): UseCouponReturn;
222
399
 
223
- export { type PaginationMode, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, useAddress, useCart, useCheckoutCoupon, useCheckoutPayment, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useOrders, useProductDetailModal, useServiceFormModal, useShopCheckout, useUserDetails, useVariantSelector, useWishlist };
400
+ export { BUY_NOW_PAYLOAD_KEY, type BuyNowError, type BuyNowItem, type InlinePlaceOrderArgs, type PaginationMode, type PublicCheckoutError, type UseBuyNowReturn, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseInlineCheckoutPaymentOptions, type UseInlineCheckoutPaymentReturn, type UsePublicCheckoutReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, useAddress, useBuyNow, useCart, useCheckoutCoupon, useCheckoutPayment, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useInlineCheckoutPayment, useOrders, useProductDetailModal, usePublicCheckout, useServiceFormModal, useShopCheckout, useUserDetails, useVariantSelector, useWishlist };