Delete a Cart

Last updated 2 months ago

You can easily remove all items from a cart.

delete
Delete 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
Authorization
required
string
The Bearer token to grant access to the API
200: OK
{
"data": [
{
"type": "cart",
"id": "360acb59-3fb7-4150-8066-ea54e850015b"
}
]
}
cURL
JavaScript SDK
Moltin Request
Swift SDK
curl -X DELETE 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)
.Delete()
.then(cart => {
// Do something
})
const { createClient } = require('@moltin/request')
const client = new createClient({
client_id: 'X'
})
const reference = 'XXXX'
client
.delete(`carts/${reference}`)
.then(cart => {
// Do something...
})
.catch(console.error)
let moltin = Moltin(withClientID: "<your client ID>")
let referenceId = 'XXXX'
self.moltin.cart.deleteCart(referenceId, completionHandler: { (result) in
switch result {
case .success(let result):
print("Cart error:", result)
case .failure(let error):
print("Cart error:", error)
}
})