Add custom properties to a shopper type
To add custom properties to a shopper type, issue a PUT
request to the /ccadmin/v1/shopperTypes/{id}
endpoint on the administration server.
Use the following format:
- The request header must specify the
x-ccasset-language
value. - The request body is a map where each key is the ID of a new property, and each value is an object that specifies the values of the attributes of the property.
- Each object is also a map, with each key being the name of an attribute and each value being the corresponding attribute value.
Note that the ID of a custom property must include the underscore character (_). This ensures that the ID will not conflict with any properties that Commerce adds to shopper types in the future. The endpoint produces an error if you attempt to create a custom property without an underscore in its ID.
The following example shows a sample request for adding two custom properties to the user shopper type:
PUT /ccadmin/v1/shopperTypes/user HTTP/1.1
Authorization: Bearer <access_token>
x-ccasset-language: en
Content-Type: application/json
{
"properties": {
"loyalty_program_member": {
"label": "Member of loyalty program?",
"type": "checkbox",
"uiEditorType": "checkbox",
"internalOnly": true,
"default": false,
"required": true,
"audienceVisibility": "all"
},
"favorite_website": {
"label": "Favorite Web Site",
"type": "shortText",
"uiEditorType": "shortText",
"internalOnly": false,
"default": null,
"required": false,
"audienceVisibility": "all"
}}}
See Settable attributes of shopper type properties for information about specifying the attribute values.
The following is a portion of the response that shows the new properties:
{
...
"properties": {
...
"loyalty_program_member": {
"writable": true,
"localizable": false,
"label": "Member of loyalty program?",
"type": "checkbox",
"uiEditorType": "checkbox",
"textSearchable": false,
"multiSelect": null,
"dimension": false,
"internalOnly": true,
"default": false,
"audienceVisibility": "all"
"editableAttributes": [
"textSearchable",
"multiSelect",
"dimension",
"internalOnly",
"default",
"label",
"required",
"audienceVisibility",
"searchable"
],
"length": 19,
"required": true,
"searchable": false
},
"favorite_website": {
"writable": true,
"localizable": false,
"label": "Favorite Web Site",
"type": "shortText",
"uiEditorType": "shortText",
"textSearchable": false,
"multiSelect": null,
"dimension": false,
"internalOnly": false,
"default": null,
"audienceVisibility": "all"
"editableAttributes": [
"textSearchable",
"multiSelect",
"dimension",
"internalOnly",
"default",
"label",
"required",
"audienceVisibility",
"searchable"
],
"length": 254,
"required": false,
"searchable": false
},
...
}
...
}