Get a Cart

get
Get a Cart by reference

https://api.moltin.com/v2/carts/:reference
Request
Response
Path Parameters
reference
required
string
A custom reference for this cart created by you
Headers
X-MOLTIN-CURRENCY
optional
string
Specifies the currency to be used for the products in the cart. Your site's default will be used if not specified
Authorization
required
string
The Bearer token to grant access to the API
Query Parameters
include
optional
string
comma delimited string of entities that can be included - valid options: items
200: OK
{
"data": {
"id": "360acb59-3fb7-4150-8066-ea54e850015b",
"type": "cart",
"links": {
"self": "https://api.moltin.com/carts/360acb59-3fb7-4150-8066-ea54e850015b"
},
"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"
}
}
}
}

You can easily get a new or existing cart by providing the unique cart reference in the request.

An empty cart will be returned for any carts that don't currently exist. See Get Cart Items for how the cart items object looks.

We don't handle creating cart references. You will need to create your own.

If you do not pass a X-MOLTIN-CURRENCY header specifying what currency you would like the cart retrieved in, it will be returned with values in your default currency.

get
Get a Cart by reference

https://api.moltin.com/v2/carts/:reference
Request
Response
Path Parameters
reference
required
string
A custom reference for this cart created by you
Headers
X-MOLTIN-CURRENCY
optional
string
Specifies the currency to be used for the products in the cart. Your site's default will be used if not specified
Authorization
required
string
The Bearer token to grant access to the API
200: OK
{
"data": {
"id": "360acb59-3fb7-4150-8066-ea54e850015b",
"type": "cart",
"links": {
"self": "https://api.moltin.com/carts/360acb59-3fb7-4150-8066-ea54e850015b"
},
"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 \
-H "Authorization: Bearer XXXX"
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const reference = 'XXXX'
Moltin.Cart(reference)
.Get()
.then(cart => {
// Do something
})
const { MoltinClient } = require('@moltin/request')
const client = new MoltinClient({
client_id: 'X'
})
const reference = 'XXXX'
client
.get(`carts/${reference}`)
.then(cart => {
// Do something...
})
.catch(console.error)

You can import createCartIdentifier from @moltin/request to create a Cart ID. See below.

const { MoltinClient, createCartIdentifier } = require('@moltin/request')
const client = new MoltinClient({
client_id: 'X'
})
const cartId = createCartIdentifier()
client
.get(`carts/${cartId}`)
.then(cart => {
// Do something...
})
.catch(console.error)
let moltin = Moltin(withClientID: "<your client ID>")
self.moltin.cart.get(forID: AppDelegate.cartID, completionHandler: { (result) in
switch result {
case .success(let result):
DispatchQueue.main.async {
print("Cart:", result)
}
case .failure(let error):
print("Cart error:", error)
}
})