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
| Field | Required | Description |
|---|---|---|
items[].pricingPlanId | Yes | Pricing plan identifier for the recommended product to add. |
items[].productRecommendationsTrackingId | No | Tracking identifier returned in sourceMetadata.trackerId from productRecommendations. |
items[].productRecommendationsSource | Conditional | Required when productRecommendationsTrackingId is provided. Supported values: ADOBE, CO_PURCHASE. |
userId | Yes | Unique identifier of the user who owns the cart. |
accountId | Yes | Unique 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
productRecommendationsSourcemust be a supported enum value (ADOBEorCO_PURCHASE).- When
productRecommendationsTrackingIdis provided,productRecommendationsSourceis required. - The same
pricingPlanIdcannot be added twice in one request. - A
pricingPlanIdthat 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
| Error | Description |
|---|---|
productRecommendationsSource is required when productRecommendationsTrackingId is provided | Tracking metadata was sent without a valid source value. |
productRecommendationsTrackingId cannot be empty | A blank tracking identifier was provided. |
pricingPlanId <id> is already in the cart | The recommended product is already in the active cart. |
pricingPlanId <id> is duplicated in the request | The 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?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!