customers/addresses
The customers/addresses template presents a customer address form page, allowing customers to edit their current addresses and add new ones.

Location
The customers/addresses template is located in the theme's templates directory templates > customers:
└── theme
├── layout
├── templates
| └── customers
| ├── addresses.json
| ...
...
Content
You should include the following content within the customers/addresses template or a part of the template:
Customer Object
You can access the Handlebars customer object to display detailed information on the page.
Standard Form Inputs
Within the form used for adding or editing an address, each address detail has standard form inputs. The table below shows each attribute along with its associated type and name attributes.
If you want to restrict your form to only allow submission for merchant-set shipping regions, you can use the country_option_tags to build your country/region selector.
If you need all countries/regions, you can use all_country_option_tags.
| Field | Type | Form Name |
|---|---|---|
| First name | text | address[first_name] |
| Last name | text | address[last_name] |
| Company | text | address[company] |
| Address 1 | text | address[address1] |
| Address 2 | text | address[address2] |
| Country | select | address[country] |
| Province | select | address[province] |
| City code | select | address[city_code] |
| City | input | address[city] |
| District code | select | address[district_code] |
| District | input | address[district] |
| ZIP/Postal Code | text | address[zip] |
| Phone Number | text | address[phone] |
Each form input for address details must have the name attribute from this table, otherwise the form will not submit successfully.
Usage
When using the customers/addresses template, you should be familiar with the following:
If you use a JSON template, any HTML or Handlebars code needs to be included in the sections referenced by the template.
How to Cascade Addresses
You should provide address cascading interactions to guide users through entering complete addresses. Address data is retrieved via the api URL delivered under window.routes.address_url. For an example implementation, refer to the assets/component-address-cascade.js file in Seed:
class AddressCascade extends HTMLElement {
...other codes
createCityOptions() {
const countryName = this.countryEl.value;
const province = this.provinceEl.value;
return this.fetchAddressNextLevel({
countryName,
province,
}).then((response) => {
this.clearOptions(this.cityEl);
if (!response.data.length) {
this.cityContainer.style.display = 'none';
this.districtContainer.style.display = 'none';
this.clearOptions(this.districtEl);
return false;
}
response.data.forEach((city) => {
this.createOption(this.cityEl, {
value: city.code,
innerHTML: city.name,
});
});
this.cityContainer.style.display = '';
return true;
});
}
}
To ensure that the SHOPLINE admin fully displays the user's address, the following input logic needs to be supplemented:
- When there are provinces under a country/region, display a dropdown showing the provinces and cities corresponding to the country/region.
- When there are no provinces under a country/region, display input fields for City and District, supporting the input of City and District.
How to Add a New Address
You can allow customers to add new addresses using the Handlebars form helper and passing the customer_address parameter to create the form:
{{#form "customer_address" return_to=routes.account_url}}
<!-- form content -->
{{/form}}
How to Edit an Address
For existing addresses, you should include a form to edit them. You can use the Handlebars form helper and pass the customer_address and address parameters to create the edit form:
{{#form "customer_address" address=customer.editing_address return_to=routes.account_url}}
<!-- form content -->
{{/form}}