Skip to main content

Add product recommendations to a cart

Use the addRecommendationsToCart mutation to add one or more recommended products to the authenticated user's active cart. Use this API after fetching recommendations with productRecommendations.

For more information on product recommendations in Checkout v2, see the release notes for Product Recommendations.

This mutation adds items to the active cart and stores recommendation tracking metadata on the cart item when tracking fields are provided.

Mutation:

mutation addRecommendationsToCart($input: AddRecommendationsToCartInput!) {
addRecommendationsToCart(input: $input) {
cart(locale: "en-US") {
id
items {
id
product {
name
}
pricingPlan {
id
}
}
pricingTotal {
amountDueAfterTax
totalTaxAmount
}
}
}
}

Sample arguments:

For a single Adobe recommendation with tracking metadata

{
"input": {
"items": [
{
"pricingPlanId": "ae1acd7c-e161-4dc1-8b35-1865138874ce",
"productRecommendationsTrackingId": "rec-tracker-123",
"productRecommendationsSource": "ADOBE"
}
],
"userId": "95cce1ea-37fb-431d-9f5a-7df387b7e8e4",
"accountId": "9faf88c2-9e58-4f5b-a009-5dc9094fe2a0"
}
}

For multiple recommendations in one request

{
"input": {
"items": [
{
"pricingPlanId": "ae1acd7c-e161-4dc1-8b35-1865138874ce",
"productRecommendationsTrackingId": "rec-tracker-123",
"productRecommendationsSource": "ADOBE"
},
{
"pricingPlanId": "60ec4489-5bd0-4d98-8e13-8fafb31c8e2",
"productRecommendationsTrackingId": "rec-tracker-456",
"productRecommendationsSource": "CO_PURCHASE"
}
],
"userId": "95cce1ea-37fb-431d-9f5a-7df387b7e8e4",
"accountId": "9faf88c2-9e58-4f5b-a009-5dc9094fe2a0"
}
}

For a recommendation without tracking metadata

{
"input": {
"items": [
{
"pricingPlanId": "ae1acd7c-e161-4dc1-8b35-1865138874ce"
}
],
"userId": "95cce1ea-37fb-431d-9f5a-7df387b7e8e4",
"accountId": "9faf88c2-9e58-4f5b-a009-5dc9094fe2a0"
}
}

Input fields

FieldRequiredDescription
items[].pricingPlanIdYesPricing plan identifier for the recommended product to add.
items[].productRecommendationsTrackingIdNoTracking identifier returned in sourceMetadata.trackerId from productRecommendations.
items[].productRecommendationsSourceConditionalRequired when productRecommendationsTrackingId is provided. Supported values: ADOBE, CO_PURCHASE.
userIdYesUnique identifier of the user who owns the cart.
accountIdYesUnique identifier of the account (company) that owns the cart.

Sample output

{
"data": {
"addRecommendationsToCart": {
"cart": {
"id": "6512b7ff875fe104e5fde6da",
"items": [
{
"id": "b7ec8290-d984-4608-bca6-f31191e61f05",
"product": {
"name": "Office 365 for Enterprises"
},
"pricingPlan": {
"id": "dfa7e728-7f2a-4c88-84e6-94d563c302a8"
}
},
{
"id": "5dc0fe86-b66c-450d-bd6b-9c4a5e19e061",
"product": {
"name": "Creative Cloud for Teams"
},
"pricingPlan": {
"id": "ae1acd7c-e161-4dc1-8b35-1865138874ce"
}
}
],
"pricingTotal": {
"amountDueAfterTax": 474.1,
"totalTaxAmount": 34.1
}
}
}
}
}

Validation behavior

  • productRecommendationsSource must be a supported enum value (ADOBE or CO_PURCHASE).
  • When productRecommendationsTrackingId is provided, productRecommendationsSource is required.
  • The same pricingPlanId cannot be added twice in one request.
  • A pricingPlanId that is already present in the active cart is rejected.

These APIs are currently available on the preview GraphQL endpoint:

https://marketplace-url/api/graphql/preview

Common errors

ErrorDescription
productRecommendationsSource is required when productRecommendationsTrackingId is providedTracking metadata was sent without a valid source value.
productRecommendationsTrackingId cannot be emptyA blank tracking identifier was provided.
pricingPlanId <id> is already in the cartThe recommended product is already in the active cart.
pricingPlanId <id> is duplicated in the requestThe same pricing plan was included more than once in items.

For more information on common GraphQL errors, refer to the section on Error handling.

Was this page helpful?