Przejdź do głównej zawartości

Interface: UseCartResult

Properties

addItems

addItems: (lines) => Promise<CartMutationOutcome>

Append line items to the cart. Resolves with { cart, warnings }.

Parameters

lines

CartLineInput[]

Returns

Promise<CartMutationOutcome>


cart

cart: CartFragment | null

Currently loaded cart, or null before the first fetch / when not found.


error

error: Error | null

Last error from any operation, or null.


isLoading

isLoading: boolean

True while any operation (fetch or mutation) is in flight.


operation

operation: ServerCartOperation | null

Which operation produced the current isLoading / error, if any.


refetch

refetch: () => Promise<CartFragment | null>

Re-fetch the cart from the backend. Resolves with the fresh cart or null.

Returns

Promise<CartFragment | null>


removeItems

removeItems: (lineIds) => Promise<CartMutationOutcome>

Remove line items by their line IDs.

Parameters

lineIds

string[]

Returns

Promise<CartMutationOutcome>


setShippingAddress

setShippingAddress: (address) => Promise<CartMutationOutcome>

Set the shipping address (full replace).

Parameters

address

CartAddressInput

Returns

Promise<CartMutationOutcome>


updateAttributes

updateAttributes: (attributes) => Promise<CartMutationOutcome>

Replace the cart's custom { key, value } attribute pairs.

Parameters

attributes

CartAttributeInput[]

Returns

Promise<CartMutationOutcome>


updateBuyerIdentity

updateBuyerIdentity: (buyerIdentity) => Promise<CartMutationOutcome>

Update buyer identity (email, phone, country, customer link, language).

Parameters

buyerIdentity

CartBuyerIdentityInput

Returns

Promise<CartMutationOutcome>


updateDiscountCodes

updateDiscountCodes: (codes) => Promise<CartMutationOutcome>

Apply discount codes (replace-all — pass [] to clear).

Parameters

codes

string[]

Returns

Promise<CartMutationOutcome>


updateItems

updateItems: (lines) => Promise<CartMutationOutcome>

Update line items (quantity, attributes) by their line IDs.

Parameters

lines

CartLineUpdateInput[]

Returns

Promise<CartMutationOutcome>


updateNote

updateNote: (note) => Promise<CartMutationOutcome>

Update the cart note / gift message.

Parameters

note

string

Returns

Promise<CartMutationOutcome>