For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
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
Hi,
We are creating a Checkout UI extension for our own store, where we need to show a drop-down list for the Buyer to select the Sales Rep for this order. Available Sales Reps are a list on the Company Location's Metafields.
How can we get the selected Location and the Location's Metafileds for a B2B customer from the UI Extension.
useCustomer is returning undefined, buyerIdentity from useExtensionAPI() only gets the customer email and we cant find a way to get B2B variables.
We get more details from a non-B2B customer, which makes no sense, the UI extension and checkout functions are supposed to be the way to customize the checkout for B2B customers. For D2C customer we already do it using liquid and JS files.
Appreciate any help.
Hi Jbriceno, You're correct that the `useCustomer` hook and `buyerIdentity` do not provide direct access to B2B-related variables in Shopify. In order to access B2B-related variables, such as the selected location, within a Checkout UI extension, you'll need to use a different approach. One possible solution is to leverage the Shopify Storefront API to retrieve the necessary information.
Here's a general outline of the steps you can follow:
This will allow you to fetch B2B-related variables and make them available in your Checkout UI extension.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
buyerIdentity {
purchasingCompany {
company
}
}
Why wouldn't this query work?
Hi Martin,
This works from a Checkout Function but not from a UI Extension. Not a clue why would Shopify restrict the data on the UI Extension....