SwissUpLabs Logo

Advanced Address Formatting

Advanced Address Formatting option is available at Stores > Configuration > Swissup Checkout > Address Autocomplete > Advanced Formatting.

Caution! When enable “Advanced Formatting”, regular Address Formatting options are overriden and not working.

Advanced Formatting

Contents

Field Format

The following JSON format is used:

{
    "*": {
        "FIELD_NAME1": "PLACEHOLDER1",
        "FIELD_NAME2": "PLACEHOLDER2"
    },
    "COUNTRY_CODE1": {
        "FIELD_NAME1": "PLACEHOLDER3"
    },
    "COUNTRY_CODE2": {
        "FIELD_NAME1": "PLACEHOLDER4"
    }
}
Field Description
* Fallback settings that will be used if currently selected country is not found in the list
COUNTRY_CODE Officially assigned ISO 3166-1 alpha-2 country code. Example: US, ES, AU.
FIELD_NAME One of the supported field names
PLACEHOLDER Combination of supported tokens

Please note that ‘*’ settings is not completely overriden with “COUNTRY_CODE” related options, but they are merged into single object.

For example, when “COUNTRY_CODE1” is selected, “FIELD_NAME1” will use “PLACEHOLDER3” and “FIELD_NAME2” will use “PLACEHOLDER2”.

Field Names and Default Placeholders

Field Name Default Placeholder
street1 "{{street_number.short_name}}{{ }}{{route.long_name}}{{, }}{{subpremise.short_name}}"
street2 ""
street3 ""
street4 ""
country_id "{{country.short_name}}"
city "{{postal_town.long_name|locality.long_name|administrative_area_level_2.long_name|sublocality_level_1.long_name}}"
postcode "{{postal_code.short_name}}{{-}}{{postal_code_suffix.short_name}}"
region "{{administrative_area_level_1.long_name}}"
region_code "{{administrative_area_level_1.short_name}}"

Available Tokens

Token Description
Separators Used when two not empty tokens found around the separator.
{{ }} Space
{{, }} Comma
{{ / }} Slash
{{-}} Dash
Custom Address Entities Entities returned by AddressAutocomplete module
{{subpremise.short_name}} Unit Number
Address Entities Entities returnes by Google Places API
{{route.long_name}} Street Name
{{street_number.short_name}} Street Number
{{country.short_name}} Country Code
{{postal_town.long_name|locality.long_name|administrative_area_level_2.long_name|sublocality_level_1.long_name}} City Name. Since Google API returns the city with different name for different countries we use possible tokens combined with a ‘|’. This means that the first non-empty value will be used.
{{postal_code.short_name}} Postcode
{{postal_code_suffix.short_name}} Postcode Suffix
{{administrative_area_level_1.long_name}} Region Name
{{administrative_area_level_1.short_name}} Region Code

Examples

Default Value

Default value includes Unit Number Placement for Australian addresses, and Neighbourhood Placement for Brazilian addresses:

{
    "*": {
        "country_id": "{{country.short_name}}",
        "street1": "{{street_number.short_name}}{{ }}{{route.long_name}}{{, }}{{subpremise.short_name}}",
        "street2": "",
        "street3": "",
        "street4": "",
        "city": "{{postal_town.long_name|locality.long_name|administrative_area_level_2.long_name|sublocality_level_1.long_name}}",
        "postcode": "{{postal_code.short_name}}{{-}}{{postal_code_suffix.short_name}}",
        "region": "{{administrative_area_level_1.long_name}}",
        "region_code": "{{administrative_area_level_1.short_name}}"
    },
    "AU": {
        "street1": "{{subpremise.short_name}}{{/}}{{street_number.short_name}}{{ }}{{route.long_name}}"
    },
    "BR": {
        "street4": "{{sublocality_level_1.long_name}}"
    }
}

Australian Unit Number Placement

{
    "AU": {
        "street1": "{{subpremise.short_name}}{{/}}{{street_number.short_name}}{{ }}{{route.long_name}}"
    }
}

Brazilian Neighbourhood Placement

{
    "BR": {
        "street4": "{{sublocality_level_1.long_name}}"
    }
}
Edit this Page