2. Add to Cart

Since we currently don't have any products within our Moltin inventory, we'll go ahead and add a custom item to the Cart.

Custom cart items are a great solution, if you manage your inventory outside of Moltin, and wish to slowly migrate your data.

Custom items are also perfect when dealing with shipping charges.‌

Add to Cart

Let's go ahead and add a custom_item to the Cart. We'll be using the same cart reference abc

Replace XXXX below with your access_token.

curl -X POST https://api.moltin.com/v2/carts/abc/items \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"type": "custom_item",
"name": "T-Shirt",
"sku": "tshirt-001",
"description": "A Moltin branded T-shirt",
"quantity": 1,
"price": {
"amount": 10000
}
}
}'

We can very easily add another custom_item to the Cart.

curl -X POST https://api.moltin.com/v2/carts/abc/items \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"type": "custom_item",
"name": "Jeans",
"sku": "jeans-orange-001",
"description": "Moltin branded jeans",
"quantity": 1,
"price": {
"amount": 12500
}
}
}'

Both of these requests will respond with the current cart items, including useful data such as display_price for each item, which provides helpful formatted currencies for items in the cart.‌

Now we have items in the cart, in the next lesson we will convert the Cart to an unpaid Order using the /checkout endpoint.