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.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Store front api has some weird behaviour about the Cart

Store front api has some weird behaviour about the Cart

bsq-jh
Shopify Partner
1 0 0

we have an app that use store front api to add/remove product to cart and recently noticed that there are 2 different format of cart id 

Format 1:  gid://shopify/Cart/Z2NwLXVzLWNlbnRyYWwxOjAxSDFWUkpFN05aWU1BWjJEMDJRU1dISzc5

Format 2:  gid://shopify/Cart/c1-cbdb4c4178dafdb65ad2fb30c5cd5d63

 

and cart with Format 1 id caused some problems. while getting cart or add line items to it. 

 

when calling cartLinesAdd, it returns error De opgegeven winkelwagen bestaat niet. (the cart does not exist.)

but meanwhile it looks like it created a new cart and added the item to it.

bsqjh_0-1686602045390.png

but when I call api to retrieve the same cart, it returns the result, but it has total amount (probably added before this become an issue ?) with no line items 

bsqjh_1-1686602224067.png

 

can someone please explain what is going on here ? what's the deal with those 2 format of ids, and possible solution for it. like how to make sure when a new cart is created, it will be the format 2 id ?

we are using 2022-10 api version, which is not deprecated yet. 

Reply 1 (1)

jovisjoseph
Shopify Partner
2 0 0

i had the same issue but for me I'm not even able to query cart with the cart in format 1. If i try to query the cart with that id i get the following result
I'm using  api/2023-10

 

 

{
	"data": {
		"cart": null
	},
	"extensions": {
		"context": {
			"country": "LT",
			"language": "NL"
		}
	}
}