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

How to get checkout or cart ID inside checkout-ui extension?

Solved

How to get checkout or cart ID inside checkout-ui extension?

Dixor
Shopify Partner
32 3 13

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. 

Accepted Solution (1)

Dixor
Shopify Partner
32 3 13

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;

 

View solution in original post

Replies 5 (5)

jc4881
Shopify Partner
4 0 0

Did you find a solution to this? I'm looking into this as well.

Dixor
Shopify Partner
32 3 13

I posted solution mate.

jc4881
Shopify Partner
4 0 0

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
Shopify Partner
4 0 0

Nevermind, found it - it matches the checkout_token field in the Admin REST API Order resource. Thanks!

Dixor
Shopify Partner
32 3 13

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;