A user account comes with a set of standard address fields – and in some cases this is enough – but additional addresses can be created for an account when necessary.
This can happen in several ways:
- From frontend via an instance of the Extranet app in Manage addresses mode
- From the backend using the built-in Addresses view on a user account
- As a part of an integration setup where user accounts and addresses are imported from an external system to the AccessUserAddresses table
To add additional addresses to a user account from backend:
- Open the user account details
- Click the Addresses button to switch to the address list (Figure 1.1)
- Click Add address in the toolbar to open the Edit address view (Figure 1.2)
As you can see, you have access to a number of standard address fields – they work in exactly the same manner as the corresponding standard user field does.
You also have the option of adding custom address fields.
Custom address fields
Custom address fields are used to hold information for which there is no standard field – pretty simple, actually. This can be necessary when working with address data from a region with a different standard address format than the one natively employed by Dynamicweb.
Custom address fields are created by navigating to Settings > Control Panel > Users and clicking Edit custom address fields (Figure 2.1)
This opens the custom address fields view (Figure 2.2) from where you can add new custom fields and specify a name, a system name, and a field type.
Frontend Address Formats
Address formats are not universal – in English-speaking countries the postal code usually comes last, on most of Europe the code precedes the town name, and in most of East-Asia addresses start with the Province and ends with the addressee. To make this simpler to reflect in frontend you can create frontend address formats for each Ecommerce country on a solution.
To do so:
- Go to Settings > Ecommerce > Internationalization > Countries
- Under Frontend address formats:
- Switch Address display mode to custom
- Enter a custom address format
You can customize both the Address display format and the Address edit format – in some scenarios, the display format will be different from the edit format, but there are also implementational differences which will be explained later in this section. For now, use the Edit format if you want to create forms using the custom format and the display format if you want to display an address using the custom format.
Once created, the custom address formats can be used whereever you have access to an order ID – the typical scenario of course being in the Shopping Cart app. In the code example below I do the following:
- Fetch CountryAddressInfo for an order based on the order ID
- Fetch display address fields for the order based on the CountryAddressInfo – this API call returns a list of strings which need only be displayed
- Fetch edit address information for the order based on the CountryAddressInfo – this API call returns a list of objects which can be used to create input fields
I then use the data to render display addresses & render a form, as appropriate. The AddressFormatEditRow object also contains properties – like IsCountryField – which can be used to create forms which work in the real world but have been left out of this example for the sake of simplicity.
Addresses are stored in the AccessUserAddress-table - this does not contain the address stored in the user standard fields.
|Field name||Data type||Length|