Skip to content

User Account Functions

The User Account drop-in provides API functions that enable you to programmatically control behavior, fetch data, and integrate with Adobe Commerce backend services.

Version: 3.0.0-beta4
FunctionDescription
createCustomerAddressCreates an address for an existing customer using the CustomerAddressesModel object as an argument.
getAttributesFormCalls the attributesForm query to retrieve EAV attributes associated with customer and customer address frontend forms.
getCountriesCalls the countries query to retrieve a list of countries..
getCustomerRetrieves the customer information for the logged-in customer.
getCustomerAddressReturns an array of addresses associated with the current customer.
getOrderHistoryListIs an asynchronous function that retrieves a list of customer orders using the customer query.
getRegionsCalls the country query to retrieve a list of states or provinces for a specific country..
getStoreConfigCalls the storeConfig query to retrieve details about password requirements..
removeCustomerAddressRemoves an address associated with the current customer.
updateCustomerUpdates the logged-in customer.
updateCustomerAddressUpdates an address associated with the current customer.
updateCustomerEmailUpdates the email address of the logged-in customer.
updateCustomerPasswordUpdates the password of the logged-in customer.

The createCustomerAddress function creates an address for an existing customer using the CustomerAddressesModel object as an argument. The function calls the createCustomerAddress mutation.

const createCustomerAddress = async (
address: CustomerAddressesModel
): Promise<string>
ParameterTypeReq?Description
addressCustomerAddressesModelYesThe new address details including street, city, region, country, postal code, and optional fields like company name and phone number.

Does not emit any drop-in events.

Returns string.

The getAttributesForm function calls the attributesForm query to retrieve EAV attributes associated with customer and customer address frontend forms. The formCode parameter must be one of the following values: customer_account_create, customer_account_edit, customer_address_create, or customer_address_edit.

const getAttributesForm = async (
formCode: string
): Promise<AttributesFormModel[]>
ParameterTypeReq?Description
formCodestringYesOne of “customer_account_create”, “customer_account_edit”, “customer_address_create”, “customer_address_edit”.

Does not emit any drop-in events.

Returns AttributesFormModel[].

The getCountries function calls the countries query to retrieve a list of countries.

const getCountries = async (): Promise<{
availableCountries: Country[] | [];
countriesWithRequiredRegion: string[];
optionalZipCountries: string[];
}>

Does not emit any drop-in events.

Promise<{
availableCountries: Country[] | [];
countriesWithRequiredRegion: string[];
optionalZipCountries: string[];
}>

See Country.

The getCustomer function retrieves the customer information for the logged-in customer. The function calls the customer query.

const getCustomer = async (): Promise<CustomerDataModelShort>

Does not emit any drop-in events.

Returns CustomerDataModelShort.

The getCustomerAddress function returns an array of addresses associated with the current customer. The function calls the customer query.

const getCustomerAddress = async (): Promise<
CustomerAddressesModel[]
>

Does not emit any drop-in events.

Promise<
CustomerAddressesModel[]
>

See CustomerAddressesModel.

The getOrderHistoryList function is an asynchronous function that retrieves a list of customer orders using the customer query. It optionally takes parameters for pagination and filtering.

const getOrderHistoryList = async (
pageSize: number,
selectOrdersDate: string,
currentPage: number
): Promise<OrderHistoryModel | null>
ParameterTypeReq?Description
pageSizenumberYesThe maximum number of results to return at once. The default value is 20.
selectOrdersDatestringYesRepresents a date filter for the orders.
currentPagenumberYesThe current page of the order history list. The default value is 1.

Does not emit any drop-in events.

Returns OrderHistoryModel or null.

The getRegions function calls the country query to retrieve a list of states or provinces for a specific country.

const getRegions = async (
countryCode: string
): Promise<RegionTransform[] | []>
ParameterTypeReq?Description
countryCodestringYesA two-letter abbreviation for the country ID.

Does not emit any drop-in events.

Returns RegionTransform[] | []. See RegionTransform.

The getStoreConfig function calls the storeConfig query to retrieve details about password requirements.

const getStoreConfig = async (): Promise<StoreConfigModel>

Does not emit any drop-in events.

Returns StoreConfigModel.

The removeCustomerAddress function removes an address associated with the current customer. The function calls the deleteCustomerAddress mutation.

const removeCustomerAddress = async (
addressId: number
): Promise<boolean>
ParameterTypeReq?Description
addressIdnumberYesAn internal ID for the address.

Does not emit any drop-in events.

Returns boolean.

The updateCustomer function updates the logged-in customer. The function calls the updateCustomerV2 mutation.

The form object keys are converted to snake_case using the convertKeysCase utility with specific mappings for firstName, lastName, middleName, and custom_attributesV2.

const updateCustomer = async (
form: Record<string,
string>
): Promise<string>
ParameterTypeReq?Description
formRecord<string, string>YesThe customer attributes to update, such as firstName, lastName, email, date of birth, and custom attributes.

Does not emit any drop-in events.

Returns string.

The updateCustomerAddress function updates an address associated with the current customer. The function calls the updateCustomerAddress mutation.

The forms object includes an addressId, which is a number representing the ID of the address to be updated and other address details as defined in CustomerAddressesModel.

const updateCustomerAddress = async (
forms: ExtendedAddressFormProps
): Promise<string>
ParameterTypeReq?Description
formsExtendedAddressFormPropsYesThe addressId and address attributes to update, such as street, city, region, country, and postal code.

Does not emit any drop-in events.

Returns string.

The updateCustomerEmail function updates the email address of the logged-in customer. The function calls the updateCustomerEmail mutation.

const updateCustomerEmail = async (
{ email, password, }: { email: string; password: string; }
): Promise<string>
ParameterTypeReq?Description
optionsstring; }YesConfiguration options for the operation.

Does not emit any drop-in events.

Returns string.

The updateCustomerPassword function updates the password of the logged-in customer. The function calls the changeCustomerPassword mutation.

const updateCustomerPassword = async (
{ currentPassword, newPassword, }: ChangeCustomerPasswordProps
): Promise<string>
ParameterTypeReq?Description
optionsChangeCustomerPasswordPropsYesAn object containing `currentPassword` (the password before it is changed) and `newPassword` (the new password).

Does not emit any drop-in events.

Returns string.

The following data models are used by functions in this drop-in.

The Country object is returned by the following functions: getCountries.

type Country = {
value: string;
text: string;
availableRegions?: {
id: number;
code: string;
name: string;
}[];
};

The CustomerAddressesModel object is returned by the following functions: getCustomerAddress.

interface CustomerAddressesModel {
firstName?: string;
lastName?: string;
city?: string;
company?: string;
countryCode?: string;
region?: { region: string; regionCode: string; regionId: string | number };
telephone?: string;
id?: string;
vatId?: string;
postcode?: string;
street?: string;
streetMultiline_2?: string;
defaultShipping?: boolean;
defaultBilling?: boolean;
uid?: string;
}

The CustomerDataModelShort object is returned by the following functions: getCustomer.

interface CustomerDataModelShort {
firstName: string;
lastName: string;
middleName: string;
dateOfBirth: string;
prefix: string;
gender: 1 | 2 | string;
suffix: string;
email: string;
createdAt: string;
[key: string]: string | boolean | number;
}

The OrderHistoryModel object is returned by the following functions: getOrderHistoryList.

interface OrderHistoryModel {
items: OrderDetails[];
pageInfo: PaginationInfo;
totalCount: number;
dateOfFirstOrder: string;
}

The RegionTransform object is returned by the following functions: getRegions.

interface RegionTransform {
text: string;
value: string;
id?: string | number;
}

The StoreConfigModel object is returned by the following functions: getStoreConfig.

interface StoreConfigModel {
baseMediaUrl: string;
minLength: number;
requiredCharacterClasses: number;
storeCode: string;
}