[**@wocart/storefront v3.1.0**](../../README)

***

[@wocart/storefront](../../README) / [index](../README) / BasketStore

# Interface: BasketStore

Basket Store Interface.

Deep module interface: simple, focused methods that hide all storage
failures, cross-tab events, line reconciliation, and normalization.

## Methods

### addLine()

> **addLine**(`line`): readonly `object`[]

Add a line. Merges with existing product+variant, caps quantities.

#### Parameters

##### line

###### href?

`string`

###### image?

`string`

###### offerId?

`string`

###### productId

`string`

###### productName

`string`

###### quantity

`number`

###### unitPrice

`number`

###### variantId?

`string`

###### variantLabel?

`string`

#### Returns

readonly `object`[]

***

### addSelections()

> **addSelections**(`line`, `selections`): readonly `object`[]

Add a choice made piece by piece — an offer of three in two sizes, as an
order's `variantSelections` carries it: one line per variant, its
quantity the pieces of that variant, as one change. All or nothing: when
the basket has no room for every new line, nothing is added.

#### Parameters

##### line

[`BasketSelectionLine`](../type-aliases/BasketSelectionLine)

##### selections

readonly [`CreateOrderVariantSelection`](CreateOrderVariantSelection)[]

#### Returns

readonly `object`[]

***

### clear()

> **clear**(): readonly `object`[]

Empty the basket.

#### Returns

readonly `object`[]

***

### getCount()

> **getCount**(): `number`

Total quantity of items in the basket.

#### Returns

`number`

***

### getLines()

> **getLines**(): readonly `object`[]

Get current snapshot of lines.

#### Returns

readonly `object`[]

***

### getSubtotal()

> **getSubtotal**(): `number`

Optimistic display subtotal. Not trusted for money.

#### Returns

`number`

***

### isPersistent()

> **isPersistent**(): `boolean`

Check if the underlying storage can persist across reloads.

#### Returns

`boolean`

***

### removeLine()

> **removeLine**(`key`): readonly `object`[]

Remove a line by its composite key.

#### Parameters

##### key

`string`

#### Returns

readonly `object`[]

***

### setQuantity()

> **setQuantity**(`key`, `quantity`): readonly `object`[]

Update quantity of an existing line. Removes if <= 0.

#### Parameters

##### key

`string`

##### quantity

`number`

#### Returns

readonly `object`[]

***

### subscribe()

> **subscribe**(`listener`): () => `void`

Subscribe to state changes (local and cross-tab). Returns unsubscribe.

#### Parameters

##### listener

[`BasketListener`](../type-aliases/BasketListener)

#### Returns

() => `void`

***

### toOrderItems()

> **toOrderItems**(): `object`[]

Convert lines to server-ready wire items for POST /store/cart/validate or order creation.

#### Returns

`object`[]
