[Cart Validation API] Are private cart attributes from the Shopify AJAX API readable?

dylanpierce
Shopify Partner
211 3 96

Hi there,

Just a quick question, the Cart Attributes object in the Cart Validation GraphQL API reference doesn't specify if it's possible to read _private_ Cart Attributes from the Online Store AJAX API.

 

Say I leave a custom private attribute on a cart in the online store:

```javascript

$.ajax({

type: 'POST',

url: window.Shopify.routes.root + 'cart.json',

dataType: 'jsonp',

data: JSON.stringify({

  __example: "Hello World",

})

}

});

```

 

When the customer attempts to check out, would the `__example` private Cart attribute be available in the input Cart.Attributes GraphQL response?


```

query RunInput {
cart {
  attribute(key: "__example") {
     value
  }
}
}

```

Would the result of `RunInput.cart.attribute` result in `Hello World`?

Founder of Real ID - Verify your customer's real IDs easily & securely with modern A.I.

Want to see it in action? Check out our demo store.

Replies 2 (2)

Liam
Shopify Staff
2731 299 769

Hi Dylan,

 

Private cart attributes are not available in the input Cart.Attributes GraphQL response, as they're part of a separate API. The Cart Validation API is designed to validate the state of the cart and does not provide access to private cart attributes. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

dylanpierce
Shopify Partner
211 3 96

Hi Liam,

Thanks for getting back to me as always.

This problem is only affecting non-Plus merchants that don't currently have access to Checkout Extensibility. We need a way to use cart validation to mark a customer as verified before they're allowed to continue to purchase.

I believe with Checkout Extensibility, the Checkout UI extensions can add metafields to unregistered guest customers, which solves the problem. But we don't have a way to decorate a cart/checkout for the Function Validation for non-Plus merchants.

Founder of Real ID - Verify your customer's real IDs easily & securely with modern A.I.

Want to see it in action? Check out our demo store.