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: 1.2.0
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.

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>
ParameterTypeReq?Description
addressCustomerAddressesModelYesThe 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[]>
ParameterTypeReq?Description
formCodestringYesOne 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>
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.

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[] | []>
ParameterTypeReq?Description
countryCodestringYesA 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>
ParameterTypeReq?Description
addressIdnumberYesAn 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>
ParameterTypeReq?Description
formRecord<string, string>YesThe 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>
ParameterTypeReq?Description
formsExtendedAddressFormPropsYesThe 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>
ParameterTypeReq?Description
optionsstring; }YesConfiguration 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>
ParameterTypeReq?Description
optionsChangeCustomerPasswordPropsYesAn 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;
}