Add items to a cart
Use the addItemsToCart API to add an item(s) to a cart. It creates a new cart if no active carts are available. Items are instead added to an active cart, if one exists already.
Mutation:
mutation addItemsToCart($input: AddItemsInput!) {
addItemsToCart(input: $input) {
cart {
id
items {
id
product {
name
}
}
pricingTotal {
amountDueAfterTax
totalTaxAmount
}
}
}
}
Sample arguments:
For a normal product
{
"input":{
"items": [
{
"pricingPlanId":"ae1acd7c-e161-4dc1-8b35-1865138874ce"
}
],
"userId": "95cce1ea-37fb-431d-9f5a-7df387b7e8e4",
"accountId": "9faf88c2-9e58-4f5b-a009-5dc9094fe2a0"
}
}
For a domain product
{
"input":{
"items": [
{
"pricingPlanId":"ae1acd7c-e161-4dc1-8b35-1865138874c",
"domain":"meter.io"
}
],
"userId": "95cce1ea-37fb-431d-9f5a-7df387b7e8e4",
"accountId": "9faf88c2-9e58-4f5b-a009-5dc9094fe2a0"
}
}
For an associated addon product
{
"input":{
"items": [
{
"pricingPlanId":"ae1acd7c-e161-4dc1-8b35-1865138874ce",
"associations": {
"pricingPlanId": "60ec4489-5bd0-4d98-8e13-8fafb31",
"type": "ADDON"
}
}
],
"userId": "95cce1ea-37fb-431d-9f5a-7df387b7e8e4",
"accountId": "9faf88c2-9e58-4f5b-a009-5dc9094fe2a0"
}
}
Sample output
{
"data": {
"addItemsToCart": {
"cart": {
"id": "6512b7ff875fe104e5fde6da",
"items": [
{
"id": "b7ec8290-d984-4608-bca6-f31191e61f05",
"product": {
"name": "Tag and Track device 1"
}
},
{
"id": "5dc0fe86-b66c-450d-bd6b-9c4a5e19e061",
"product": {
"name": "Stacked Web App (DO NOT EDIT OR CHANGE)"
}
}
],
"pricingTotal": {
"amountDueAfterTax": 474.1,
"totalTaxAmount": 34.1
}
}
}
}
}
Common errors
For information on some of the common errors related to this mutation, refer to the section on Error handling.
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!