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?

Show Loyalty Banner

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;
}

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 '@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;
}