How should I get the customer email related to the checkout with UI checkout extensions?

How should I get the customer email related to the checkout with UI checkout extensions?

LouiseEH
Shopify Partner
36 3 4

Hi,


I have an app with a UI extension, where I would like to get the email of the customer related to the current checkout. For this purpose I would like to use the useEmail hook c.f. https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/buyer-identity/useemail. I only get "undefined" though - even when I am logged in. I am suspecting it is due to the fact that it is protected data and the app has to go through the "Protected customer data access" approval process, but in the approval form, it states:

Only apps that are distributed on the App Store need to submit their access for review
If you’re installing on a development store, select your data use in step 1 to access protected customer data. 

So I guess it should be possible to get the customer email in the checkout UI extension via the useEmail hook without the approval.
If that is the case, why is the value undefined - even when the customer is logged in?
Code snippet:

...
const email = useEmail()
console.log('email', email)
...

Thanks,
-Louise

Replies 0 (0)