Skip to main content

Authenticated Account
API

The API for interacting with an account in which the customer is fully authenticated.

The base API object provided to this and other customer-account extension targets.

Anchor to authenticatedAccount
authenticatedAccount
required

Information about the authenticated account.

Was this section helpful?

Anchor to useAuthenticatedAccountCustomer
useAuthenticatedAccountCustomer()

Returns the current authenticated Customer. The value is undefined if the customer isn't authenticated.

| undefined
Was this section helpful?

Anchor to useAuthenticatedAccountPurchasingCompany
useAuthenticatedAccountPurchasingCompany()

Provides information about the company of the authenticated business customer. The value is undefined if a business customer isn't authenticated.

| undefined
Was this section helpful?

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.

Was this section helpful?

Getting the company and location of the customer

/* See the locales/en.default.json tab for the translation keys and values for this example */
import {
Banner,
extension,
} from '@shopify/ui-extensions/customer-account';

export default reactExtension(
'customer-account.order-index.block.render',
() => <Extension />,
);

function Extension() {
const i18n = useI18n();
const purchasingCompany =
useAuthenticatedAccountPurchasingCompany();
const companyLocationId =
purchasingCompany?.location?.id;

if (
companyLocationId &&
isLocationClosed(companyLocationId)
) {
return (
<Banner
status="warning"
title={i18n.translate(
'closedLocationMessage',
)}
/>
);
}
return null;
}

function isLocationClosed(locationId: string) {
return true;
}