We’re porting our app’s ORDER_STATUS script tag over to a Checkout UI Extension. The app updates the cart’s attributes, and we’ll need to sync those same fields to the order’s metafields.
The final problem we need to solve is updating the order with details collected from the Checkout UI Extension.
How are you supposed to be able to associate a cart with a specific order? There’s no cartToken attribute for an order in the Admin Order GraphQL API, and the cart_token field is deprecated on the REST Order API.
Is there some other method of associating carts with orders? Or is this an oversight by the API design?
Technically for now, yes. But the issue is this field is deprecated, so we can’t build around this checkout_token property that is being removed in future API versions for the Admin Order REST API:
I couldn’t find cart attributes on the order, but it does look like you can leave metafields. So we’ll have to generate our own unique token, store it as a metafield, and that would be the connection between our databased stored pre-checkout details and the order.
We’re experimenting with this approach now, but seems like a workaround for what cart_token or checkout_token were supposed to do. Not sure why they’re being removed.
@SBD We’re also trying to figure out this issue. We’re using the checkout token for the time-being, but we can’t rely on it since it’s due for removal. There are no other keys on the checkout or order which is unique across all orders which we can use to identify the order down the line. Checkout token was solving the issue pretty neatly.
The original post trying to solve associating a cart with an order, we suggest writing cart attributes, reading those during checkout, then saving them to order metafieldsduring checkout. Their app already writes cart attributes so this still seems like the best solution.
For others, there are a few alternatives: cart attributes (for Online Store), cart metafields (for headless), order metafields, etc.