Accounts Addresses Controller - Liquid Controller Reference
On this page
Description
The Accounts Addresses controller serves the signed-in customer’s address book. A customer must be signed in. Each customer sees only their own entries.
| Property | Value |
|---|---|
| Controller | Accounts::AddressesController |
| Liquid Template Path | controllers/accounts/addresses/ |
| Namespace | Accounts |
Actions
| Action | HTTP Method | Route | Result |
|---|---|---|---|
index |
GET | /account/addresses |
Renders the account page |
new |
GET | /account/addresses/new |
Renders the account page |
create |
POST | /account/addresses |
Redirects to /account/addresses, or back to the form with errors |
edit |
GET | /account/addresses/:id/edit |
Renders the account page |
update |
PATCH, PUT | /account/addresses/:id |
Redirects to /account/addresses, or back to the form with errors |
destroy |
DELETE | /account/addresses/:id |
Redirects to /account/addresses |
On the pages it renders, current_request.params.section is addresses. On edit, current_request.params.identifier is the id of the entry being edited. Use these in the account page template to show the address book section.
The create and update actions accept is_default_shipping and is_default_billing. A true value makes the entry that default. Deleting a default entry moves the default to another entry.
Example
Create a theme template with the key controllers/accounts/addresses/destroy to keep a customer from deleting their last address:
```liquid
{% before %} {% if current_customer.addresses.size <= 1 %} {% redirect to: current_store.addresses_path, alert: “Keep at least one address in your address book.” %} {% endif %} {% endbefore %} ```
See how Liquid controllers work for the phases and the tags you can use in them.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.