New Shopify Certification now available: Liquid Storefronts for Theme Developers

Add line item to existing checkout

workFlo
Tourist
10 1 0

I want to add a product variant to the existing line items of my checkout. For now I am listening on the webhook "checkout created" which sends me information about the checkout (id etc.).

Now I want to use the checkoutLineItemsAdd mutation to add the product variant to the checkout. However, it does not work. It always returns me:

 

 

 

{ data: { checkoutLineItemsAdd: { checkout: null } } }

 

 

 


My assumption is that the checkoutId field is wrong. What I currently do is I take the token key and the key parameter from the "abandonded_checkout_url" property and concatenate the string like this:

 

 

 

 

{
checkoutId: 'gid://shopify/Checkout/[TOKEN_FROM_WEBHOOK]?key=[KEY_FROM_ABANDONED_CHECKOUT]
}

 

 

 

 
But I assume this is wrong. Anyone here knows how the format of the checkoutId looks like?

Replies 2 (2)
workFlo
Tourist
10 1 0

Sidenote: Also tried to encode in base64 because I read that in another thread but it did not work either.

workFlo
Tourist
10 1 0

I managed to see the error. It says "invalid checkout id". So my assumption was correct. Any one here to help?