Discussing Shopify Functions development, deployment, and usage in Shopify apps.
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`?
Want to see it in action? Check out our demo store.
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
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.
Want to see it in action? Check out our demo store.