Przejdź do głównej zawartości

Interface: CartManagerLifecycleCallbacks

Optional lifecycle callbacks fired around every cart and checkout operation the hook drives. Centralise cross-cutting side-effects — a global loading indicator, a toast on failure, a router refresh on success — in one place instead of wrapping each call site.

onMutationError fires only for failures you can surface to the buyer: its error carries a backend-translated message. Cart expiry is delivered through its own dedicated channel (onExpired) — it carries an SDK-internal message and does NOT trigger onMutationError. A transient missing-cart error that the manager recovers from (by recreating the cart) resolves as success, so it never reaches the error callback either.

Callbacks are invoked defensively: a throwing callback never rejects the underlying mutation.

Extended by

Properties

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


onMutationStart?

optional onMutationStart?: (operation) => void

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

Parameters

operation

CartManagerOperation

Returns

void


onMutationSuccess?

optional onMutationSuccess?: (operation) => void

Fired after an operation resolves successfully.

Parameters

operation

CartManagerOperation

Returns

void