User account functions
The user account drop-in component provides API functions that allow developers to retrieve and display account details, including shipping and billing addresses and previous orders.
createCustomerAddress
The createCustomerAddress
function creates an address for an existing customer using the CustomerAddressesModel
object as an argument. The function calls the createCustomerAddress
mutation.
The CustomerAddressesModel
object has the following fields:
Returns
Returns a promise that resolves to a string, which could be a success message or an error message.
Usage
To create a new address:
getAttributesForm
The getAttributesForm
function uses 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
.
Returns
Returns a promise that resolves to an AttributesFormModel
array. It has the following structure:
Usage
To get attributes associated with the customer_address_edit
form:
getCountries
The getCountries
function uses the countries
query to retrieve a list of countries.
Returns
Returns a promise that resolves to arrays of countries, regions, and postal codes.
Usage
To get a list of countries:
getCustomer
The getCustomer
function retrieves the customer information for the logged-in customer. The function uses the customer
query.
Returns
Returns a promise that resolves to CustomerDataModelShort
object:
Usage
To get details about the customer:
getCustomerAddress
The getCustomerAddress
function returns an array of addresses associated with the current customer. The function uses the customer
query.
Returns
Returns a promise that resolves to CustomerAddressesModel
object:
Usage
To get information about the customer address:
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.
Returns
Returns a promise that resolves to an OrderHistory
object or null.
Usage
To get a list of customer orders:
getRegions
The getRegions
function uses the country
query to retrieve a list of states or provinves for a specific country.
Returns
Returns a promise that resolves to a RegionTransform
array:
Usage
To get a list of regions for a specific country:
getStoreConfig
The getStoreConfig
function uses the storeConfig
query to retrieve details about password requirements.
Returns
Returns a promise that resolves to a StoreConfigModel
object:
Usage
To get the store configuration:
removeCustomerAddress
The removeCustomerAddress
function removes an address associated with the current customer. The function uses the deleteCustomerAddress
mutation.
Returns
Returns a promise that resolves to a boolean value that indicates whether the address was removed.
Usage
To remove an address:
updateCustomer
The updateCustomer
function updates the logged-in customer. The function uses 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
.
Returns
Returns a promise that resolves to a string, which could be a success message or an error message.
Usage
To update the customer:
updateCustomerAddress
The updateCustomerAddress
function updates an address associated with the current customer. The function uses 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
.
The CustomerAddressesModel
object has the following shape:
Returns
Returns a promise that resolves to a string, which could be a success message or an error message.
Usage
To update the customer address:
updateCustomerEmail
The updateCustomerEmail
function updates the email address of the logged-in customer. The function calls the updateCustomerEmail
mutation.
Returns
Returns a promise that resolves to a string, which could be a success message or an error message.
Usage
To update the customer’s email address:
updateCustomerPassword
The updateCustomerPassword
function updates the password of the logged-in customer. The function calls the changeCustomerPassword
mutation.
Returns
Returns a promise that resolves to a string, which could be the customer’s email if the password change is successful, or an error message if there are errors.
Usage
To update the customer’s password: