checkout ui - how to access contact and customer information

chriscoyne
Shopify Partner
7 0 2

I have started working on a a checkout ui extension. What I want to do is access the customer's email that they enter. Is there a way to get this information from the contact field on the checkout information page, perhaps using a hook or object from the useExtensionAPI?

 

As a followup, will the customer object obtained from useExtensionAPI only be defined if the customer is logged in?

 

Thank you.

Reply 1 (1)
dgtlmonk
Shopify Partner
33 3 4

There's a BuyerIdentity property https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/apis/standardapi#properties-propertydeta...

Note that this  requires access to protected customer data.

 

App() {
 const { buyerIdentity : { customer }}  = useApi()
 // .. you now have access to customer object (i.e. customer.id, customer.email) ..
}