Using the Storefront API, how do you populate the cart_token field when creating the checkout?

New Member
4 0 0

I am creating the checkout from scratch using the Storefront API, however, I am unable to figure out how to populate and tie the source cart (cart_token) to this checkout/order. I am ready to store the cart + checkout independently in my own database, but it would be helpful if this were somehow linked together so I know where the checkout came from. 

0 Likes
Excursionist
22 1 4

Is there a reason you are storing carts and checkouts separately? If you're using the Storefront API, you can model the behavior of a cart using JS Buy SDK.

 

If there is a specific reason you need to use Carts, and then redirect to a Checkout, I don't think it's possible: https://community.shopify.com/c/Shopify-APIs-SDKs/How-to-create-checkout-URL-with-cart-token/td-p/58...

0 Likes
New Member
4 0 0

Hi @tolgapaksoy ! Thanks for the prompt reply. 

 

No reason aside from not knowing a better method. 

 

You sent me another post that essentially models the line-items - this is what I'm already doing. However, populating the cart_token itself as the Checkout object becomes an order still yet to be clear to me. 

0 Likes
Excursionist
22 1 4

@petergAtArriveddid you read the response from Shopify staff? They say it is not possible.

 

If you're not using the Online Store extension, you should be able to create "carts" by just creating Checkouts with JS Buy SDK. And then you will always have a checkout URL available.

 

As for Checkouts becoming Orders: As soon as a Checkout is completed using a payment, it will be converted into an Order by Shopify.

0 Likes
Highlighted
New Member
4 0 0

Hi @tolgapaksoy Thanks for the prompt responses! 

 

Hmm, that's inconvenient. I have meta data I track dependent on the cart_token but it looks like I'll have to track that internally elsewhere. Thank you! 

0 Likes