Goal: Build a Checkout UI extension that validates the shipping address and restricts checkout to the customer’s saved shipping address for logged-in users.
Limitation: The Checkout UI Extensions SDK cannot access a customer’s saved shipping address directly. This is by design for privacy/security.
Workarounds: Fetch the default shipping address via either:
Storefront API (requires the customer’s access token), or
Admin API (server-side, with appropriate app scopes).
Key requirement: The Storefront API will not return customer data without a valid customer access token. You cannot query arbitrary customers by email via Storefront; access is scoped to the authenticated customer.
Latest attempt: A code snippet shows a Storefront query trying to fetch customers by email. It works in the Admin API but not in Storefront, consistent with the token/privacy constraints. The snippet is central to understanding the issue.
Status: Unresolved. Next steps are to either supply a customer access token to a Storefront query (e.g., retrieve the authenticated customer and its defaultAddress), or call the Admin API from a secure backend to fetch the default address.
We are developing a Checkout UI extension to validate the customer’s shipping address. Our product can be purchased by logged-in users. We are preventing changes to the customer’s shipping address during checkout and only accepting the saved customer shipping address. This feature is part of our Checkout UI extension validation app.
We are able to obtain the customer’s inputted shipping address using ‘useShippingAddress’ and retrieve customer information using ‘useCustomer.’ However, we have encountered an issue in obtaining the customer’s saved shipping address.
Could you please provide guidance on how to access the customer’s saved shipping address in the Checkout UI extension?
The Checkout UI Extensions SDK does not directly provide access to the customer’s saved shipping address. This is a part of Shopify’s design to ensure customer data privacy and security.
As a workaround, you can use the Storefront API or Admin API to fetch the customer’s default shipping address (as well as other details such as name, email, etc).
Please remember, due to privacy concerns, you’ll need the customer’s access token to fetch this information. Hope this helps!
I utilized the query provided above to retrieve the customer’s default address using the Storefront API. Unfortunately, it’s not functioning as expected. To isolate the issue, I tested this query in the Shopify GraphQL app. I was able to obtain the customer information when I used the Admin API, which is puzzling.
Could you please provide insights on what might be causing this discrepancy between the Storefront and Admin APIs, and if there’s a potential solution to get the customer’s default address using the Storefront API?