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

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?

1 Like

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/1551881

Best!

1 Like