App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi there.
How i can obtain cart token or checkout/cart id inside extension?
import { extension, TextField } from "@shopify/ui-extensions/checkout"; export default extension("purchase.checkout.delivery-address.render-before", async (root, api) => { console.log('api', api); }
I already try to find it inside api object. And got no luck.
Solved! Go to the solution
This is an accepted solution.
The solution to this is use checkoutToken
And it is only available in react extension build at the moment.
let api = useApi();
const checkoutToken = api.checkoutToken.current;
Did you find a solution to this? I'm looking into this as well.
I posted solution mate.
Thank you! How are you using the checkout token to connect it back to the cart id from the storefront session though? I'm looking for a way to connect a checkout session to a storefront session.
Nevermind, found it - it matches the checkout_token field in the Admin REST API Order resource. Thanks!
This is an accepted solution.
The solution to this is use checkoutToken
And it is only available in react extension build at the moment.
let api = useApi();
const checkoutToken = api.checkoutToken.current;