Next Commerce

addCartLines

Add product to a cart

Arguments

input·AddCartLinesInput!non-nullinput

Return type

AddCartLinesPayloadobject
success·Booleanscalar
errors·ExpectedErrorTypescalar
cart·CartNodeobject
clientMutationId·Stringscalar
Mutation Reference
mutation AddCartLines($input: AddCartLinesInput!) {
  addCartLines(input: $input) {
    success
    errors
    clientMutationId
  }
}
Variables
{
  "input": {
    "lines": [
      {
        "quantity": 1,
        "productPk": 1,
        "subscription": {
          "interval": "<your-value>",
          "intervalCount": 1
        },
        "isUpsell": true
      }
    ],
    "clientMutationId": "<your-value>",
    "cartId": "<your-value>"
  }
}
JSON Response
{
  "data": {
    "addCartLines": {
      "success": true,
      "errors": null,
      "cart": {
        "abandoned": true,
        "attribution": {
          "id": "<id>",
          "utmSource": "<your-value>",
          "utmMedium": "<your-value>",
          "utmCampaign": "<your-value>",
          "utmTerm": "<your-value>",
          "utmContent": "<your-value>",
          "gclid": "<your-value>",
          "campaign": "<your-value>",
          "metadata": {},
          "affiliate": "<your-value>",
          "subaffiliate1": "<your-value>",
          "subaffiliate2": "<your-value>",
          "subaffiliate3": "<your-value>",
          "subaffiliate4": "<your-value>",
          "subaffiliate5": "<your-value>"
        },
        "dateCreated": "2026-01-01T00:00:00Z",
        "lines": [
          {
            "product": {
              "isPublic": "...",
              "parent": "...",
              "slug": "...",
              "description": "...",
              "metaTitle": "...",
              "metaDescription": "...",
              "recommendedProducts": "...",
              "rating": "...",
              "dateCreated": "...",
              "dateUpdated": "...",
              "isDiscountable": "...",
              "title": "...",
              "excerpt": "...",
              "upc": "...",
              "structure": "...",
              "ranking": "...",
              "attributes": "...",
              "variantAttributes": "...",
              "images": "...",
              "children": "...",
              "id": "...",
              "pk": "...",
              "requiresShipping": "...",
              "purchaseInfo": "...",
              "primaryImage": "...",
              "subscriptionInfo": "...",
              "url": "...",
              "metadata": "..."
            },
            "quantity": 1,
            "priceCurrency": "<your-value>",
            "dateCreated": "2026-01-01T00:00:00Z",
            "dateUpdated": "2026-01-01T00:00:00Z",
            "isUpsell": true,
            "interval": "<your-value>",
            "intervalCount": 1,
            "attributes": [
              {
                "value": "...",
                "option": "..."
              }
            ],
            "pk": 1,
            "unitPriceExclTax": "<your-value>",
            "unitPriceInclTax": "<your-value>",
            "linePriceExclTax": "<your-value>",
            "linePriceInclTax": "<your-value>",
            "linePriceExclTaxInclDiscounts": "<your-value>",
            "linePriceInclTaxInclDiscounts": "<your-value>",
            "discountValue": "<your-value>"
          }
        ],
        "id": "<id>",
        "pk": 1,
        "user": {
          "id": "<id>",
          "lastLogin": "2026-01-01T00:00:00Z",
          "isActive": true,
          "email": "<your-value>",
          "phoneNumber": "<your-value>",
          "firstName": "<your-value>",
          "lastName": "<your-value>",
          "ip": "<your-value>",
          "language": "<your-value>",
          "isBlocked": true,
          "userType": "LEAD",
          "acceptsMarketing": true,
          "metadata": {},
          "userAgent": "<your-value>",
          "firstPurchaseDate": "2026-01-01T00:00:00Z",
          "lastPurchaseDate": "2026-01-01T00:00:00Z",
          "dateJoined": "2026-01-01T00:00:00Z",
          "agentMarketingAttributions": [
            {
              "id": "...",
              "utmSource": "...",
              "utmMedium": "...",
              "utmCampaign": "...",
              "utmTerm": "...",
              "utmContent": "...",
              "gclid": "...",
              "campaign": "...",
              "metadata": "...",
              "affiliate": "...",
              "subaffiliate1": "...",
              "subaffiliate2": "...",
              "subaffiliate3": "...",
              "subaffiliate4": "...",
              "subaffiliate5": "..."
            }
          ],
          "pk": 1
        },
        "checkoutUrl": "<your-value>",
        "currency": "<your-value>",
        "totalInclTax": "<your-value>",
        "totalExclTax": "<your-value>",
        "totalInclTaxExclDiscounts": "<your-value>",
        "totalExclTaxExclDiscounts": "<your-value>",
        "totalDiscount": "<your-value>",
        "numItems": 1,
        "numLines": 1,
        "offerDiscounts": [
          {
            "name": "<your-value>",
            "description": "<your-value>",
            "amount": "<your-value>"
          }
        ],
        "voucherDiscounts": [
          {
            "name": "<your-value>",
            "description": "<your-value>",
            "amount": "<your-value>",
            "voucher": {
              "name": "...",
              "code": "...",
              "startDatetime": "...",
              "endDatetime": "..."
            }
          }
        ],
        "metadata": {},
        "subscriptionPreview": {
          "totalGroupsInclTax": "10.00",
          "totalGroupsExclTax": "10.00",
          "subscriptionRebills": [
            {
              "currency": "...",
              "displayTaxes": "...",
              "frequency": "...",
              "interval": "...",
              "intervalCount": "...",
              "lines": "...",
              "totalExclTax": "...",
              "totalInclTax": "...",
              "totalTax": "...",
              "shippingPrice": "..."
            }
          ]
        }
      },
      "clientMutationId": "<your-value>"
    }
  }
}