Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
{
    "countries": {
        "sc_ois_1": [
            "FR",
            "CH"
            "GB"
        ]
    }
}

...

Add custom fields

sales channelsYou can take personnalisation a step further by adding custom fields to the customer form

Classic fields

Field

Type

Mandatory

Description

name

string

Yes

This key is used to give the identifier of the field.

This id must match with parameters used in POST /customers request or PATCH /customers/<id>

Expand
titleAllowed values
  • Contact fields: title, first_name, last_name, phone_number, email, company_name, mobile_number

  • Address fields: address_1, address_2, address_3, city, zip_code, country

  • Custom fields: information.{custom_field}, external_id

target

string

No

Indicates whether the field should be saved in the customer structure or the address structure. By default, customer is applied.

Only used for information.{custom_field} and external_id names, the others are automatically redirected to the right structure.

Expand
titleAllowed values
  • customer

  • address

type

string

No

Type of the field. By default, the text type is used.

Expand
titleAllowed values
  • text - returns a string

  • email - returns a string

  • tel- returns a string

  • password - returns a string

  • flip-switch - returns a boolean

  • list - returns a string or an array of string depending on the ‘multiple’ value

required

boolean

No

Indicates whether the field is mandatory or not. By default, fields are optional.

position_after

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 :first. If multiple elements are placed in first position, they will be placed in the order in which they are configured.

If not defined, the element form will be placed at the bottom of the form.

Expand
titleExamples
  • If I want my field to appear after the country field of the default form : "position_after": "country"

  • If I want my field to appear at the top of the form : "position_after": ":first"

  • If I want my field to appear at the bottom of the form, I leave it blank.

validation

object

No

Enables to add custom validation to the field, which will be checked when the create button is clicked.

Expand
titleAllowed values

These 3 types of validation can be configured alone or together.

  • min_characters (int) - minimum number of characters required

  • max_characters (int) - maximum number of characters required

  • regex (string) - Custom regular expression used to verify the field. More information Here.

  • error_translation_key (string) - Overrides the default translation key of the error message with a custom one if the regex is invalid.

Info

The error_translation_key specified here must then be translated from the Configuration > Store App > Translations page.

Expand
titleExamples
  • Require a 5-digit postcode

Code Block
languagejson
"validation": {
  "min_characters": 5,
  "max_characters": 5
}
  • Use a custom validation for UK postcode and add a custom message if the field is invalid

Code Block
languagejson
"validation": {
  "regex": "^([a-zA-Z]){1}([0-9][0-9]|[0-9]|[a-zA-Z][0-9][a-zA-Z]|[a-zAZ][0-9][0-9]|[a-zAZ][0-9]|[0-9][a-zAZ]){1}([ ])*([0-9][a-zA-z][a-zA-z]){1}$",
  "error_translation_key": "UK_postcode_error_message"
}
Note

Regexes with ‘\’ must escape by doubling it "\\"

...