A developer is attempting to access the checkout token on a thank you page within a Shopify checkout UI extension, but the api.checkoutToken?.current returns undefined.
Key Issue:
The checkout token is not available on the post-purchase/thank you page since checkout is already completed at that point
The developer needs some identifier to send to their backend for order tracking
Proposed Solution:
Use orderId instead of checkoutToken on the thank you page
Shopify’s developer documentation includes a tutorial demonstrating how to access order data on post-purchase pages
The orderId can be used for tracking and further backend processing
Current Status:
The original poster acknowledges the suggestion but was hoping for a more straightforward approach that doesn’t rely on webhooks
Another user has asked a follow-up question about accessing orderID on the thank you page using checkout UI extensions
Summarized with AI on November 11.
AI used: claude-sonnet-4-5-20250929.
i try to access the checkout token inside the thank you page block but it’s return undefine,
const api = useApi();
console.log("token", api.checkoutToken?.current);
I need some kind of id to track back the order, as i will be sending it to the backend. I try to access the cart token but as window isn’t available on web worker it was not possible to extract it from url or from local storage. Neither did useStorage or api.storage work.
I’m bit lost here on how to acquire id, either checkout token, cartToke, or some other (but it trace back to order) inside thank you block.
On the Post Purchase page, the checkoutToken is not available directly as the checkout is already completed at this point. Instead, you can use the orderId to track the order (there’s a tutorial that demonstrates this on our developer docs). You can use this orderId for tracking or further processing in your backend.