Skip to main content

Interface: AddItemOptions

Defined in: composables/react/useCart.ts:30

Arguments for UseCartReturn.addItem.

Properties

afterAddToCart?

optional afterAddToCart?: (cart, item) => void

Defined in: composables/react/useCart.ts:46

Fires after the item is added — receives the updated cart and the matched line item.

Parameters

cart

Cart

item

CartMainItem | null

Returns

void


cartId?

optional cartId?: string

Defined in: composables/react/useCart.ts:50

Explicit cart id to add into; defaults to the hook's resolved cart.


childItems?

optional childItems?: number[]

Defined in: composables/react/useCart.ts:36

Child product ids for bundle/cluster composite items.


cluster?

optional cluster?: Cluster

Defined in: composables/react/useCart.ts:34

Cluster the product belongs to, when adding a configured cluster item.


createCart?

optional createCart?: boolean

Defined in: composables/react/useCart.ts:52

When true and no cart exists, resolves/creates one before adding.


enableStockValidation?

optional enableStockValidation?: boolean

Defined in: composables/react/useCart.ts:48

When true, rejects the add if product.inventory.totalQuantity is below quantity.


notes?

optional notes?: string

Defined in: composables/react/useCart.ts:40

Free-text line-item notes.


onAddToCart?

optional onAddToCart?: (product, clusterId?, quantity?, childItems?, notes?, price?) => Cart

Defined in: composables/react/useCart.ts:44

Override: when provided, replaces the SDK call and returns the cart synchronously.

Parameters

product

Product

clusterId?

number

quantity?

number

childItems?

object[]

notes?

string

price?

number

Returns

Cart


price?

optional price?: number

Defined in: composables/react/useCart.ts:42

Explicit unit price override.


product

product: Product

Defined in: composables/react/useCart.ts:32

Product to add.


quantity

quantity: number

Defined in: composables/react/useCart.ts:38

Quantity to add.