E-commerce API
E-commerce Cart Items API
Add, update, and remove the line items attached to an e-commerce cart.
Get the items of a cart
If you want to get a list items of the given cart, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/itemsRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| cart_id | integer | yes | Must provide valid cart id |
| limit | integer | no | Defaults to 100 |
| page | integer | no | Defaults to 1 |
Response
{
"data": [
{
"id": "45676855678345",
"product": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"categories": [
{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
},
{
"id": "1234566457534278",
"name": "Category 2",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
]
},
"variant": "product variant",
"quantity": 1,
"price": 123.4
}
],
"links": {
"first": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items?page=1",
"last": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"path": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items",
"per_page": 100,
"to": 1,
"total": 1
}
}Add/update a cart item
You can add or update a cart item.
If you want to create a cart item for a given shop, use this POST request
POST https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/itemsIf you want to update the cart item for the given shop, use this PUT request
PUT https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items/:item_idRequest body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| ecommerce_product_id | integer | yes | The id of the product to add to the cart |
| variant | string | no | The product's variant information. |
| quantity | integer | no | The products quantity. Defaults to 1. |
| price | float | no | The cart item's price. Defaults to 0. |
{
"ecommerce_product_id": "64375689754",
"price": 123.40,
"variant": "Color black, size medium",
"quantity": 2,
}Response
If the cart item was created:
Response Code: 201 Created{
"data": {
"id": "45676855678345",
"product": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"categories": [
{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
},
{
"id": "1234566457534278",
"name": "Category 2",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
]
},
"variant": "Color black, size medium",
"quantity": 2,
"price": 123.4
}
}Error
Response Code: 422 Unprocessable EntityThe error response will contain information about the invalid data.
{
"message": "The given data was invalid.",
"errors": {
"ecommerce_product_id": ["The ecommerce_product_id must be provided."]
}
}Fetch a cart item
If you want to create a cart item, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items/:item_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| cart_id | integer | yes | Must provide valid cart id |
| item_id | integer | yes | Must provide valid cart item id |
GET https://connect.mailerlite.com/api/ecommerce/shops/31986843064993537/carts/319868430643456756/items/34567564567Response
If the shop, cart and cart item exist:
Response Code: 200 OK{
"data": {
"id": "45676855678345",
"product": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"categories": [
{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
},
{
"id": "1234566457534278",
"name": "Category 2",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
]
},
"variant": "Color black, size medium",
"quantity": 2,
"price": 123.4
}
}Error
If the shop, cart or cart item cannot be found:
Response Code: 404 Not FoundFetch total cart items count
If you want to fetch the total cart items count, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items?limit=0Request parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| cart_id | integer | yes | Must provide valid cart id |
| limit | integer | yes | Value must be 0 |
Response
Response Code: 200 OK{
"total": 123
}Delete a cart item
If you want to delete a cart item, send this DELETE request
DELETE https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/carts/:cart_id/items/:item_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| cart_id | integer | yes | Must provide valid cart id |
| item_id | integer | yes | Must provide valid cart item id |
Response
Response code: 200 OK{
"data": {
"id": "45676855678345",
"product": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"categories": [
{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
},
{
"id": "1234566457534278",
"name": "Category 2",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
]
},
"variant": "Color black, size medium",
"quantity": 2,
"price": 123.4
}
}Error
Response code: 404 Not Found