> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cocartapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cart

> Commands for managing the cart.

<Warning>
  At the moment the commands are only documented here while they are still being tested. An announcement in the future will provide details when they will be usable.
</Warning>

## Get Cart

Get the contents of a cart.

```bash theme={"system"}
wp cocart cart get
```

### Arguments

<ParamField path="cart_key" type="string">
  The cart key.
</ParamField>

<ParamField path="user_id" type="int">
  The user ID.
</ParamField>

```bash theme={"system"}
wp cocart cart get --cart_key=t_978655cffb069bbc97e8cdd2991d3c
wp cocart cart get --user_id=174
```

## Clear Cart

Clear the contents of a cart.

```bash theme={"system"}
wp cocart cart clear
```

### Arguments

<ParamField path="cart_key" type="string">
  The cart key.
</ParamField>

<ParamField path="user_id" type="int">
  The user ID.
</ParamField>

**Examples**

```bash theme={"system"}
wp cocart cart clear --cart_key=t_978655cffb069bbc97e8cdd2991d3c
wp cocart cart clear --user_id=174
```

## Add to Cart

Add an item to the cart.

```bash theme={"system"}
wp cocart cart add
```

### Arguments

<ParamField path="cart_key" type="string">
  The cart key.
</ParamField>

<ParamField path="user_id" type="int">
  The user ID.
</ParamField>

<ParamField path="product_id" type="int" required>
  The product ID.
</ParamField>

<ParamField path="quantity" type="int">
  The quantity of the product.
</ParamField>

```bash theme={"system"}
wp cocart cart add --cart_key=t_978655cffb069bbc97e8cdd2991d3c --product_id=247
wp cocart cart add --user_id=174 --product_id=247
```

## Remove Item

Remove an item from the cart.

```bash theme={"system"}
wp cocart cart remove
```

### Arguments

<ParamField path="cart_key" type="string">
  The cart key.
</ParamField>

<ParamField path="user_id" type="int">
  The user ID.
</ParamField>

<ParamField path="item_key" type="int" required>
  The item key.
</ParamField>

```bash theme={"system"}
wp cocart cart remove --cart_key=t_978655cffb069bbc97e8cdd2991d3c --item_key=70efdf2ec9b086079795c442636b55fb
wp cocart cart remove --user_id=174 --item_key=70efdf2ec9b086079795c442636b55fb
```

## Update Item

Update the quantity of an item in the cart.

```bash theme={"system"}
wp cocart cart update
```

### Arguments

<ParamField path="cart_key" type="string">
  The cart key.
</ParamField>

<ParamField path="user_id" type="int">
  The user ID.
</ParamField>

<ParamField path="item_key" type="int" required>
  The item key.
</ParamField>

<ParamField path="quantity" type="int" required>
  The quantity of the item.
</ParamField>

```bash theme={"system"}
wp cocart cart update --cart_key=t_978655cffb069bbc97e8cdd2991d3c --item_key=70efdf2ec9b086079795c442636b55fb --quantity=2
wp cocart cart update --user_id=174 --item_key=70efdf2ec9b086079795c442636b55fb --quantity=2
```
