Authenticated AccountAPI
The API for interacting with an account in which the customer is fully authenticated.
Anchor to standardapiStandardApi
The base API object provided to this and other customer-account
extension targets.
- Anchor to authenticatedAccountauthenticatedAccountAuthenticatedAccountrequired
Information about the authenticated account.
Docs_Standard_AuthenticatedAccountApi
- authenticatedAccount
Information about the authenticated account.
AuthenticatedAccount
export interface Docs_Standard_AuthenticatedAccountApi
extends Pick<StandardApi<any>, 'authenticatedAccount'> {}
AuthenticatedAccount
- customer
Provides the customer information of the authenticated customer.
ReadonlySignalLike<Customer | undefined>
- purchasingCompany
Provides the company info of the authenticated business customer. If the customer is not authenticated or is not a business customer, this value is `undefined`.
ReadonlySignalLike<PurchasingCompany | undefined>
export interface AuthenticatedAccount {
/**
* Provides the company info of the authenticated business customer.
* If the customer is not authenticated or is not a business customer, this value is `undefined`.
*/
purchasingCompany: ReadonlySignalLike<PurchasingCompany | undefined>;
/**
* Provides the customer information of the authenticated customer.
*/
customer: ReadonlySignalLike<Customer | undefined>;
}
ReadonlySignalLike
Represents a read-only value managed on the main thread that an extension can subscribe to. Example: Checkout uses this to manage the state of an object and communicate state changes to extensions running in a sandboxed web worker. This interface is compatible with Preact's ReadonlySignal: https://github.com/preactjs/signals/blob/a023a132a81bd4ba4a0bebb8cbbeffbd8c8bbafc/packages/core/src/index.ts#L700-L709
- subscribe
(fn: (value: T) => void) => () => void
- value
T
export interface ReadonlySignalLike<T> {
readonly value: T;
subscribe(fn: (value: T) => void): () => void;
}
Customer
Information about the authenticated customer. {% include /apps/checkout/privacy-icon.md %} Requires access to [protected customer data](/docs/apps/store/data-protection/protected-customer-data).
- id
Customer ID.
string
export interface Customer {
/**
* Customer ID.
*
* @example 'gid://shopify/Customer/123'
*/
id: string;
}
PurchasingCompany
- company
Include information of the company of the logged in business customer.
Company
- location
Include information of the company location of the logged in business customer.
CompanyLocation
export interface PurchasingCompany {
/**
* Include information of the company of the logged in business customer.
*/
company: Company;
/**
* Include information of the company location of the logged in business customer.
*/
location?: CompanyLocation;
}
Company
- id
Company ID.
string
export interface Company {
/**
* Company ID.
*/
id: string;
}
CompanyLocation
- id
Company location ID.
string
export interface CompanyLocation {
/**
* Company location ID.
*/
id: string;
}
Show Loyalty Banner
examples
Show Loyalty Banner
Preact
import '@shopify/ui-extensions/preact'; import {render} from 'preact'; export default async () => { render(<Extension />, document.body); }; function Extension() { const orderStatusCustomerId = shopify.authenticatedAccount.customer.value .id; const authenticatedCustomerId = shopify.authenticatedAccount.customer.value .id; if ( authenticatedCustomerId && orderStatusCustomerId?.endsWith( authenticatedCustomerId, ) ) { return ( <s-banner> <s-link href="extension:manageLoyaltyPoints/"> {shopify.i18n.translate( 'manageLoyaltyPoints', )} </s-link> </s-banner> ); } return null; }
locales/en.default.json
{ "manageLoyaltyPoints": "Manage Loyalty Points" }
Anchor to examplesExamples
Anchor to example-getting-the-company-and-location-of-the-customerGetting the company and location of the customer
You can access the company and location of the authenticated business customer to implement location specific logic.
Getting the company and location of the customer
examples
Getting the company and location of the customer
description
You can access the company and location of the authenticated business customer to implement location specific logic.
Preact
/* See the locales/en.default.json tab for the translation keys and values for this example */ import '@shopify/ui-extensions/preact'; import {render} from 'preact'; export default async () => { render(<Extension />, document.body); }; function Extension() { const purchasingCompany = shopify.authenticatedAccount ?.purchasingCompany?.value; const companyLocationId = purchasingCompany?.location.id; if ( companyLocationId && isLocationClosed(companyLocationId) ) { return ( <s-banner status="warning"> {shopify.i18n.translate( 'closedLocationMessage', )} </s-banner> ); } return null; } function isLocationClosed(locationId: string) { return true; }
locales/en.default.json
{ "closedLocationMessage": "This location is temporarily closed for inventory cleanup." }