Get Cart Items

If a Cart does not exist with a provided reference, one will be created and an empty cart items array will be returned.

get
Get Cart Items by Cart reference

https://api.moltin.com/v2/carts/:reference/items
Request
Response
Path Parameters
reference
required
string
A custom reference for this cart created by you
Headers
Authorization
required
string
The Bearer token to grant access to the API
Query Parameters
include
optional
string
tax_items
200: OK
{
"data": [],
"meta": {
"display_price": {
"with_tax": {
"amount": 0,
"currency": "",
"formatted": "0"
},
"without_tax": {
"amount": 0,
"currency": "",
"formatted": "0"
}
},
"timestamps": {
"created_at": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z"
}
}
}
cURL
JavaScript SDK
Moltin Request
Swift SDK
curl -X GET https://api.moltin.com/v2/carts/:reference/items \
-H "Authorization: Bearer XXXX"
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const reference = 'XXXX'
Moltin.Cart(reference)
.Items()
.then(cart => {
// Do something
})
const { MoltinClient } = require('@moltin/request')
const client = new MoltinClient({
client_id: 'X'
})
const reference = 'XXXX'
client
.delete(`carts/${reference}/items`)
.then(itemst => {
// Do something...
})
.catch(console.error)
let moltin = Moltin(withClientID: "<your client ID>")
let referenceId = 'XXXX'
self.moltin.cart.items(forCartID: referenceId) { (result) in
switch result {
case .success(let result):
DispatchQueue.main.async {
print("Cart items:", result.data)
}
case .failure(let error):
print("Cart error:", error)
}
}
}