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.
| Function | Description |
|---|---|
createCustomerAddress | Creates an address for an existing customer using the CustomerAddressesModel object as an argument. |
getAttributesForm | Calls the attributesForm query to retrieve EAV attributes associated with customer and customer address frontend forms. |
getCountries | Calls the countries query to retrieve a list of countries.. |
getCustomer | Retrieves the customer information for the logged-in customer. |
getCustomerAddress | Returns an array of addresses associated with the current customer. |
getOrderHistoryList | Is an asynchronous function that retrieves a list of customer orders using the customer query. |
getRegions | Calls the country query to retrieve a list of states or provinces for a specific country.. |
getStoreConfig | Calls the storeConfig query to retrieve details about password requirements.. |
removeCustomerAddress | Removes an address associated with the current customer. |
updateCustomer | Updates the logged-in customer. |
updateCustomerAddress | Updates an address associated with the current customer. |
updateCustomerEmail | Updates the email address of the logged-in customer. |
updateCustomerPassword | Updates the password of the logged-in customer. |
createCustomerAddress
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
address | CustomerAddressesModel | Yes | The new address details including street, city, region, country, postal code, and optional fields like company name and phone number. |
Events
Does not emit any drop-in events.
Returns
Returns string.
getAttributesForm
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[]>| Parameter | Type | Req? | Description |
|---|---|---|---|
formCode | string | Yes | One of “customer_account_create”, “customer_account_edit”, “customer_address_create”, “customer_address_edit”. |
Events
Does not emit any drop-in events.
Returns
Returns AttributesFormModel[].
getCountries
The getCountries function calls the countries query to retrieve a list of countries.
const getCountries = async (): Promise<{ availableCountries: Country[] | []; countriesWithRequiredRegion: string[]; optionalZipCountries: string[];}>Events
Does not emit any drop-in events.
Returns
Returns Promise<{ availableCountries: Country[] | []; countriesWithRequiredRegion: string[]; optionalZipCountries: string[]; }>. See Country.
getCustomer
The getCustomer function retrieves the customer information for the logged-in customer. The function calls the customer query.
const getCustomer = async (): Promise<CustomerDataModelShort>Events
Does not emit any drop-in events.
Returns
Returns CustomerDataModelShort.
getCustomerAddress
The getCustomerAddress function returns an array of addresses associated with the current customer. The function calls the customer query.
const getCustomerAddress = async (): Promise< CustomerAddressesModel[]>Events
Does not emit any drop-in events.
Returns
Returns `Promise< CustomerAddressesModel[]
. See [CustomerAddressesModel`](#customeraddressesmodel).
getOrderHistoryList
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
pageSize | number | Yes | The maximum number of results to return at once. The default value is 20. |
selectOrdersDate | string | Yes | Represents a date filter for the orders. |
currentPage | number | Yes | The current page of the order history list. The default value is 1. |
Events
Does not emit any drop-in events.
Returns
Returns OrderHistoryModel or null.
getRegions
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[] | []>| Parameter | Type | Req? | Description |
|---|---|---|---|
countryCode | string | Yes | A two-letter abbreviation for the country ID. |
Events
Does not emit any drop-in events.
Returns
Returns RegionTransform[] | []. See RegionTransform.
getStoreConfig
The getStoreConfig function calls the storeConfig query to retrieve details about password requirements.
const getStoreConfig = async (): Promise<StoreConfigModel>Events
Does not emit any drop-in events.
Returns
Returns StoreConfigModel.
removeCustomerAddress
The removeCustomerAddress function removes an address associated with the current customer. The function calls the deleteCustomerAddress mutation.
const removeCustomerAddress = async ( addressId: number): Promise<boolean>| Parameter | Type | Req? | Description |
|---|---|---|---|
addressId | number | Yes | An internal ID for the address. |
Events
Does not emit any drop-in events.
Returns
Returns boolean.
updateCustomer
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
form | Record<string, string> | Yes | The customer attributes to update, such as firstName, lastName, email, date of birth, and custom attributes. |
Events
Does not emit any drop-in events.
Returns
Returns string.
updateCustomerAddress
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
forms | ExtendedAddressFormProps | Yes | The addressId and address attributes to update, such as street, city, region, country, and postal code. |
Events
Does not emit any drop-in events.
Returns
Returns string.
updateCustomerEmail
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
options | string; } | Yes | Configuration options for the operation. |
Events
Does not emit any drop-in events.
Returns
Returns string.
updateCustomerPassword
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
options | ChangeCustomerPasswordProps | Yes | An object containing `currentPassword` (the password before it is changed) and `newPassword` (the new password). |
Events
Does not emit any drop-in events.
Returns
Returns string.
Data Models
The following data models are used by functions in this drop-in.
Country
The Country object is returned by the following functions: getCountries.
type Country = { value: string; text: string; availableRegions?: { id: number; code: string; name: string; }[];};CustomerAddressesModel
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;}CustomerDataModelShort
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;}OrderHistoryModel
The OrderHistoryModel object is returned by the following functions: getOrderHistoryList.
interface OrderHistoryModel { items: OrderDetails[]; pageInfo: PaginationInfo; totalCount: number; dateOfFirstOrder: string;}RegionTransform
The RegionTransform object is returned by the following functions: getRegions.
interface RegionTransform { text: string; value: string; id?: string | number;}StoreConfigModel
The StoreConfigModel object is returned by the following functions: getStoreConfig.
interface StoreConfigModel { baseMediaUrl: string; minLength: number; requiredCharacterClasses: number; storeCode: string;}