How to associate a cart with an order?

Hello,

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?

Hey @dylanpierce

Checking with the Checkout UI folks and will report back.

Hey @dylanpierce

From the Checkout UI team:


Could they use a checkoutToken instead? or even the attributes API directly?

I did not find a way to get a cart token from a UI extension - checking if this is by design.

Hi @SBD

Could they use the checkoutToken?

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:

or even the attributes API directly?

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.

Thanks @dylanpierce - passing along your feedback.

@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.

We also have the issue for our app. Does your team really want to remove checkout_token without any alternative?

We also depend on the checkoutToken being kept alive. There is no other way to smoothly identify an order from the Thank You extension on our backend.

I would imagine removing the checkoutToken will affect thousands of stores so if it is going ahead a replacement value would be vital.

Thanks everyone. Passing along your feedback.

From the Checkout Extensibility folks:

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 metafields during 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.

@MathewsJoseph , @the_h , @Bloggle_team , please let me know if this doesn’t cover your use case so I can provide more feedback.

Hey SBD, what about cases where cart attributes are discarded - like express checkout and “Pay Now” functionality where there is no cart?

Please don’t deprecate or remove checkout and cart token from order. core of our app functionality depends on it.