Dixor
November 1, 2023, 12:35pm
1
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.
jc4881
November 29, 2023, 8:31pm
2
Did you find a solution to this? I’m looking into this as well.
Dixor
November 29, 2023, 8:38pm
3
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;
1 Like
jc4881
November 29, 2023, 8:52pm
5
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.
jc4881
November 29, 2023, 8:55pm
6
Nevermind, found it - it matches the checkout_token field in the Admin REST API Order resource . Thanks!