Skip to main content

customers/addresses

The customers/addresses template renders the customer addresses page, which allows customers to view and manage their current addresses, as well as add new ones.

Tip

Refer to the customers/addresses template and its main section in Dawn for an example implementation.

An example of the customer addresses template in Dawn

The customers/addresses template is located in the templates > customers directory of the theme:

└── theme
├── layout
├── templates
| └── customers
| ├── addresses.json
| ...
...

You should include the following in your customers/account template or a section inside of the template:

You can access the Liquid customer object to display the customer account details.

Anchor to Standard form inputsStandard form inputs

Inside forms for adding or editing an address, there are standard form inputs for each address detail. The table below shows each, with their associated type and name attributes.

Tip

If you want to limit your form to accept submissions for only the places that you ship to, then you can use country_option_tags to build your country selector. If you want to return all countries, then you can use all_country_option_tags. For an example of using all_country_option_tags as a data source to build a selector in a form, refer to the main-addresses.liquid file in the Dawn GitHub repository.

Inputtypename
First nametextaddress[first_name]
Last nametextaddress[last_name]
Companytextaddress[company]
Address 1textaddress[address1]
Address 2textaddress[address2]
Citytextaddress[city]
Countryselectaddress[country]
Provinceselectaddress[province]
ZIP/Postal Codetextaddress[zip]
Phone Numberteladdress[phone]
Caution

The form inputs for each address detail must have the name attributes from this table, or the form won't submit successfully.


When working with the customers/account template, you should familiarize yourself with the following:

Tip

If you're using a JSON template, then any HTML or Liquid code needs to be included in a section that's referenced by the template.

You can allow customers to add a new address with the Liquid form tag and accompanying 'customer_address', customer.new_address parameters:

Example

{% form 'customer_address', customer.new_address %}
<!-- form content -->
{% endform %}

Inside the form, you need to include the standard form inputs for capturing the various address details.

Anchor to Edit an existing addressEdit an existing address

With each existing address, you should include a form to edit it. You can add this form with the Liquid form tag and accompanying 'customer_address', address parameters:

Example

{% for address in customer.addresses %}
<!-- address details -->

{% form 'customer_address', address %}
<!-- form content -->
{% endform %}
{% endfor %}

Inside the form, you need to include the standard form inputs for capturing the various address details.

With each existing address, you should include the option to delete it. You can add this option by including the following form:

<form className="address-delete-form"
method="post"
action="/account/addresses/{{ address.id }}"
>
<input type="hidden" name="_method" value="delete" />
<button type="submit">{{ 'customer.addresses.delete' | t }}</button>
</form>
Tip

You should couple the above form with JavaScript to prompt customers to confirm that they'd like to delete an address before actually performing the deletion.


Was this page helpful?