Przejdź do głównej zawartości

Interface: UseCartManagerOptions

Optional configuration for useCartManager. All fields additive — calling the hook with no arguments preserves the original cookie-driven behaviour.

Extends

Properties

cookieDebug?

optional cookieDebug?: (event) => void

Optional debug sink — emits a phase: 'cookie' DebugEvent whenever the cart-id cookie is set or cleared (including the clear() that complete() performs after checkout). Wire it to the same transport the GraphQL client uses for a single shared debug timeline.

Parameters

event

DebugEvent

Returns

void


initialCartId?

optional initialCartId?: string | null

Server-known cart-id seed used when the cart-id cookie is empty on mount. Cookie wins when present; the seed only fills the gap on the first interaction. Eagerly promoted to the cookie store so cross-tab tabs and standard recovery semantics operate on a canonical value.

Accepts either a bare cart id ("<cartId>") or the composite cookie value ("<cartId>.<secret>"). Pass the composite when the cart secret is known server-side (e.g. read from the cart-id cookie in a Server Component) so reads and writes reach the seeded cart; a bare id degrades to a fresh cart on the first write.

See the hook-level @example Server-known cart-id block for the full Server-Component → Client-Component data flow. Use for env seed (dev), magic-link checkout, embedded iframe (parent supplies cart-id), customer service "view this cart", multi-cart B2B selectors.


onMutationError?

optional onMutationError?: (operation, error) => void

Fired when an operation fails with a buyer-surfaceable error. Cart expiry is routed to onExpired instead, not here.

Parameters

operation

CartManagerOperation

error

Error

Returns

void

Inherited from

CartManagerLifecycleCallbacks.onMutationError


onMutationStart?

optional onMutationStart?: (operation) => void

Fired when an operation starts, before the request is sent.

Parameters

operation

CartManagerOperation

Returns

void

Inherited from

CartManagerLifecycleCallbacks.onMutationStart


onMutationSuccess?

optional onMutationSuccess?: (operation) => void

Fired after an operation resolves successfully.

Parameters

operation

CartManagerOperation

Returns

void

Inherited from

CartManagerLifecycleCallbacks.onMutationSuccess