Set custom properties on a shopper profile
After adding new custom properties to the user
shopper type,
you can use the Admin API to set the values of these properties on shopper
profiles.
This section applies to Open Storefront Framework (OSF) and Storefront Classic.
You can issue a PUT
request to the
/ccadmin/v1/profiles/{id}
endpoint on the administration server to
set the values of custom properties on an existing shopper profile, or issue a
POST
request to the /ccadmin/v1/profiles
endpoint
to set these and other properties when you create a new shopper profile. Custom
properties you create on the user shopper type are automatically exposed to these
endpoints.
The following example shows a sample request body for setting the two custom properties created in the previous section on an existing shopper profile:
{
"loyalty_program_member": true,
"favorite_website": www.oracle.com
}
The following shows the response body returned:
{
"receiveEmail": "yes",
"shippingSurchargePriceList": null,
"lastName": "Anderson",
"locale": "en_US",
"priceListGroup": null,
"links": [
{
"rel": "self",
"href": "http://myserver.example.com:7002/ccadmin/v1/profiles/se-570031"
}
],
"repositoryId": "se-570031",
"id": "se-570031",
"loyalty_program_member": true,
"email": "kim@example.com",
"shippingAddresses": [
{
"lastName": "Anderson",
"postalCode": "13202",
"phoneNumber": "212-555-1977",
"county": null,
"state": "NY",
"address1": "21 Cedar Ave",
"address2": null,
"firstName": "Kim",
"repositoryId": "se-980031",
"city": "Syracuse",
"country": "US"
}
],
"translations": {},
"daytimeTelephoneNumber": null,
"favorite_website": "www.oracle.com",
"firstName": "Kim",
"shippingAddress": {
"lastName": "Anderson",
"postalCode": "13202",
"phoneNumber": "212-555-1977",
"county": null,
"state": "NY",
"address1": "21 Cedar Ave",
"address2": null,
"firstName": "Kim",
"repositoryId": "se-980031",
"city": "Syracuse",
"country": "US"
}
}
Note that the values of custom profile properties can be set on the storefront using a custom widget that accesses the UserViewModel
. The view model can then call the updateProfile
REST endpoint to update the data on the server. For details, see Access custom properties using the UserViewModel.