# Товары из корзины

## Работа с товарами из корзины

{% hint style="info" %}
Для этого метода вам нужно знать id корзины. Его можно получить из API [работа с заявками](https://developer.lpmotor.ru/zayavki/leads).
{% endhint %}

### Описание

<mark style="color:blue;">`GET`</mark> `https://api.lpmotor.ru/v1/cart/{cartId}/product`

#### Path Parameters

| Name   | Type    | Description |
| ------ | ------- | ----------- |
| cartId | integer | ID корзины  |

#### Headers

| Name                                            | Type    | Description     |
| ----------------------------------------------- | ------- | --------------- |
| X-Api-User-Id<mark style="color:red;">\*</mark> | integer | ID пользователя |
| Authorization<mark style="color:red;">\*</mark> | string  | API токен       |

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
  {
    "id": 0,
    "product_id": 0,
    "name": "string",
    "sku": "string",
    "price": "string",
    "amount": 0,
    "is_bonus": true,
    "discount": "string"
  }
]
```

{% endtab %}
{% endtabs %}

### Примеры

{% tabs %}
{% tab title="CURL" %}

```bash
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/cart/<<cart_id>>/product"
```

{% endtab %}

{% tab title="PHP(CURL)" %}

```php
<?php
$ch = curl_init();
$url = 'https://api.lpmotor.ru/v1/cart/' . $cartId. '/product';

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt(
    $ch,
    CURLOPT_HTTPHEADER,
    [
        'Host: api.lpmotor.ru',
        'X-Api-User-Id: ' . $userId,
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Accept: application/json',
    ]
);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

$result = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$responseData = json_decode($result, true);

curl_close($ch);
```

{% endtab %}

{% tab title="PHP(Guzzle)" %}

```php
<?php
$client = new GuzzleHttp\Client([
    'base_uri' => 'https://api.lpmotor.ru',
    'headers'  => [
        'Content-Type'  => 'application/json',
        'Accept'        => 'application/json',
        'X-Api-User-Id' => $userId,
        'Authorization' => 'Bearer ' . $apiKey,
    ],
]);
$response = $client->get('/v1/cart/' . $cartId. '/product');
$statusCode = $response->getStatusCode();
$responseData = json_decode((string)$response->getBody(), true);
```

{% endtab %}

{% tab title="JavaScript(Axios)" %}

```javascript
http = Axios.create({
    baseURL: "https://api.lpmotor.ru",
    timeout: 30000,
    headers: {
        "Content-Type" : "application/json",
        "Accept"       : "application/json",
        "Cache-Control": "no-cache, no-store, must-revalidate",
        "X-Api-User-Id": userId,
        "Authorization": "Bearer " + myApiKey,
    }
});
http.get("/v1/cart/" + cartId + "/product")
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
```

{% endtab %}
{% endtabs %}
