Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Shopify Storefront Cart API. Shop can't see created carts

Shopify Storefront Cart API. Shop can't see created carts

dmytro_kushnir
Visitor
2 0 1

Hello guys!
Recently, I've integrated a cart API via storefront on my service.

For example, I've implemented create and get cart methods:

https://shopify.dev/api/storefront/2022-04/queries/cart
https://shopify.dev/api/storefront/2022-04/mutations/cartCreate

Those queries give me the correct response:

Create:

{
"data": {
"cart": {
"id": "gid://shopify/Cart/123456",
"createdAt": "2022-05-24T12:36:53Z",
"updatedAt": "2022-05-24T12:36:54Z",
"lines": {
"edges": [
{
"node": {

Get

{
"data": {
"id": "gid://shopify/Cart/123456",
"createdAt": "2022-05-24T12:36:53Z",
"updatedAt": "202

However, when I try to  update cart cookie on my Site to get the cart being updated and call an AJAX request (or just reload the page):


jQuery.getJSON('/cart.json', function(cart) {
console.log(cart)
} );

There will not be a cart response. 
And vice-versa. When On the shop site, I add some Variant to the basket, then get this cart id, and try to get the information about the cart via Storefront API; I've got:

"cart": null,
"userErrors": [
{
"field": [
"cartId"
],
"message": "The specified cart does not exist."
}
]

Can somebody explain why this can happen?


Reply 1 (1)

Cenco
Shopify Partner
9 0 1

Hi!

 

I also try to figure it out. Maybe it is not possible. This post here has simmilarities:

 

https://community.shopify.com/c/shopify-apps/get-cartid-with-graphql-storefront-api-null/td-p/155188...

 

Best!

---