# $cart->add()

> Adds item to cart.

- Source: `src/Cart.php#L78` <https://github.com/wagnerwagner/merx/blob/2.0.0-alpha.11/src/Cart.php#L78>

```php
$cart->add(Wagnerwagner\Merx\ListItem|array|string $data): Wagnerwagner\Merx\Cart
```

## Parameters

| Name | Type | Default |
| --- | --- | --- |
| `$data` | `Wagnerwagner\Merx\ListItem\|array\|string` | `–` |

## Return type

`Wagnerwagner\Merx\Cart`

## Exceptions

| Type | Description |
| --- | --- |
| `Exception` | error.merx.cart.add |

## Description

```php
$cart->add('products/nice-shoes'); // ID of a ProductPage
$cart->add('page://L1cJEiOOQI3VzljV'); // UUID of a ProductPage
$cart->add(['key' => 'individual-shoes', 'page' => 'products/nice-shoes']); // Array including key
$cart->add(new ListItem(key: 'nice-socks', price: 10])); // Custom LitItem
```

## Parent class

`Wagnerwagner\Merx\Cart`
