Default customer form
Default fields
By default, when the catalogue is activated, a standard form is proposed with the following fields:
Default field | Type | Mandatory | Default Validation |
---|---|---|---|
Last Name | text | Yes | No |
First Name | text | Yes | No |
Yes | Yes | ||
Phone Number | tel | Yes | Yes |
Country | list | Yes | Yes |
Address 1 | text | Yes | No |
Address 2 | text | No | No |
City | text | Yes | No |
Postal code | text | Yes | No |
This is what the default customer form looks like:
Specific configurations on the default form
Invert the position of the first and last names: so that the first name appears first and the last name second, you need to add the configuration
"customer.invert_names" : true
in the Configuration > Store App > Pages > Catalog > Specific settings page in the Options section.{ "customer": { "invert_names": true } }
Change the list of countries:
The default form proposes the following countries: France, Belgium, Germany, Italy, Luxembourg, Spain, Switzerland, United Kingdom. An override can be made per sales channel using the configuration "countries.{sales_channel}.{list of countries}"
in the Configuration > Store App > Pages > Catalog > Specific settings page in the Options section.
Country codes must be in ISO-3166 format. Logos and translations will add themselves in the Store App.
{ "countries": { "sc_ois_1": [ "FR", "CH" "GB" ] } }
Add custom fields
You can take personnalisation a step further by adding custom fields to the customer form. To do this, add the required fields to the configuration customer.custom_fields.{sales_channel}[{custom_fields_structure}]
in the Configuration > Store App > Pages > Catalog > Specific settings page in the Options section.
If the fields added are to be applied to all the project's sales channels, then the field "_ALL_"
must be given in the {sales_channel}
part.
Here is a configuration applied to all the sales channels with ...
being the structure of the custom fields that we will see below.
{ "customer": { "custom_fields": { "_ALL_": [ { ... } ] } } }
Custom fields structure
Inside the {sales_channel}
entity ( or "_ALL_"
) there is an array of objects. Each object corresponds to a custom field to be added to the form. Here is the configuration to be entered for each custom field.
Field | Type | Mandatory | Description |
---|---|---|---|
| string | Yes | This key is used to give the identifier of the field. This id must match with parameters used in |
| string | No | Indicates whether the field should be saved in the Only used for |
| string | No | Type of the field. By default, the |
| boolean | No | Indicates whether the field is mandatory or not. By default, custom fields are optional. |
| string | No | This key defines the name of the form element to which it must be placed after. Please note, the form element must be in the default form or declared before in the same form. It it also possible to place the element on the top of the form with the value If not defined, the element form will be placed at the bottom of the form. |
| object | No | Enables to add custom validation to the field, which will be checked when the create button is clicked. Regexes with ‘\’ must escape by doubling it "\\" |
In case of lists
If the type of field added is a list, then additional configurations must be added inside the structure.
Field | Type | Mandatory | Description |
---|---|---|---|
| array[string] | Yes | List of values displayed in the drop down. Options inside will be translated with the key |
| bool | No | Indicates if multiple selection can be done. |
| bool | No | Indicates if drop down elements are searchable. |
| string | No | Indicates the pre-selected option. |
Examples
Change classic fields
Request entries
Regarding the address:
address_1
- sent in thecustomer.addresses.[0].lines.[0]
field of thePOST /customers
queryaddress_2
- sent in thecustomer.addresses.[0].lines.[1]
field of thePOST /customers
querycity
- sent in thecustomer.addresses.[0].city
field of thePOST /customers
queryzip_code
- sent in thecustomer.addresses.[0].zip_code
field of thePOST /customers
querycountry
- sent in thecustomer.addresses.[0].regions.country.code
field of thePOST /customers
query
Regarding the contact - sent in the
customer.addresses.[0].contact
ANDcustomer.contact
fields of thePOST /customers
querytitle
first_name
last_name
phone_number
email
company_name
mobile_number
Regarding custom information
information.{custom_field}
sent in thecustomer.addresses.[0].information
field if target = address / sent in thecustomer.contact
field if target = addressexternal_id
sent in thecustomer.external_id
field. The target need to be set as customer.
Please note, the label of the field will be translated based on the translation key crm.<name>
.
External CRM
External CRM may raised error (exemple email adress/phone number already used).
If so, project interface MUST return a 409 error including:
field
that is the field related to the conflit. Value MUST beemail
orphone_number
message
which is the error message to display in the interface
The error message will be display on the form.