.. _addresses:
=========
Addresses
=========
``store.addresses`` provide to you logged user's addresses.
``Address`` object represent an customer address (for shipping or billing) or
user data profile. Some attribute are only available for "profile" type address.
``with_scope``, ``paginate`` liquid tag are available with ``store.addresses``.
A customer have only one "profile" type address.
It isn't possible to update ``address_type`` value or remove address with
"profile" type.
------------------------
Attributes
------------------------
The ``store.addresses`` item has the following attributes:
.. csv-table:: address attributes
:header: "Name", "Type", "Desciption"
:widths: 15, 15, 70
"id", "Integer", Address ID"
"address_type", "String", "``profile`` for user data or ``address`` for shipping or invoice address"
"city", "String", "City"
"country", "Object", "Object with country id and name"
"display_name", "String", "Address name (firstname and lastname)"
"is_company", "Boolean", ""
"name", "String", "Address name"
"opt_in", "Boolean", ""
"opt_out", "Boolean", ""
"phone", "String", "Phone number"
"ref", "String", ""
"state", "String", "State ID (US Addresses)"
"street", "String", "Address"
"street2", "String", "Address"
"vat", "String", "VAT identification number (for company profile)"
"zip", "String", "Zip code"
Example :
Display available shipping or billing addresses of logged user
.. code-block:: liquid
{% with_scope address_type: "address" %}
{% for address in store.addresses %}
{{address.display_name}}
{{address.street}}
{{address.street2}}
{{address.zip}} - {{address.city}}
{{address.country_id.name}}
{% endfor %}
{% endwith_scope %}
Display login user profile data
.. code-block:: liquid
{% with_scope address_type: "profile" %}
{% assign profile = store.addresses.first %}
{{profile.display_name}}
{{profile.street}}
{{profile.street2}}
{{profile.zip}} - {{profile.city}}
{{profile.country_id.name}}
{% endwith_scope %}
A user have only one profile address.
Actions
=======
--------------------------------
Add shipping or billing address
--------------------------------
To add an address to logged user's address book you need to submit a form to
"invader/address/create" action with all address paramaters required.
``available_countries`` provide countries list set up to the store on Odoo.
Only available if ``address_type`` is "address".
*Controller* invader/address/create
HTML form to add address
.. code-block:: html
--------------------------------
Update address
--------------------------------
To update an address you have to submit a form to
"invader/address//update" action with all address paramaters
updated. ```` represent the address ID.
``available_countries`` provide countries list set up to the store on Odoo.
*Controller* invader/address//update
HTML form to update address
.. code-block:: html
--------------------------------
Remove address
--------------------------------
To remove an address you need to submit a form to
"invader/address//remove" action.
```` represent the address ID.
Only available if ``address_type`` is "address".
*Controller* invader/address//remove
HTML form to remove address
.. code-block:: html