If you are running multiple sites on your Commerce Cloud instance, shopper profiles are shared by all of these sites. If a shopper registers on one site running on the instance, the shopper’s profile is automatically available on all sites running on the instance.

However, the values of certain properties in the profile can be site-specific. Currently, the receiveEmail property is the only site-specific property you can set.

When you create a shopper profile using a POST request, you can specify a site using the x-ccsite header, as described in Use the APIs on instances running multiple sites. The resulting profile applies to all of the sites on your Commerce Cloud instance, but the value you provide for receiveEmail applies only to the site you specify. (If you do not specify a site, the value is applied to the default site only.) On all other sites, the value of this property defaults to no. You can modify the receiveEmail setting on a specific site using a PUT request. For example:

PUT /ccadmin/v1/profiles/120000  HTTP/1.1
Content-Type: application/json
Authorization: Bearer <access_token>
x-ccsite: 100001

{
    "receiveEmail": "yes"
}

Similarly, if you use a GET request to view a profile, the value of receiveEmail returned reflects the site specified in the x-ccsite header, or the default site if no site is specified.

Set a site-specific profile property for multiple sites

If your Commerce Cloud instance is running multiple sites, shoppers can set site-specific profile properties for each site individually. For example, the storefront for each site can provide a checkbox for setting the receiveEmail property, with the setting applying only to the current site.

A drawback of this approach is that in order to configure settings on all sites, a shopper must access each site separately. To simplify profile configuration, you may instead want to provide a way for the shopper to configure multiple sites in one place.

To enable this, you can modify your storefront to use the updateSiteProperties endpoint in the Store API. This endpoint sets the values of site-specific properties of the current profile (the profile in the current calling context). Note that the current profile must be for a registered shopper, which means the shopper must be logged in.

For example, the following call sets the value of the receiveEmail property of the current profile for two different sites:

PUT /ccstore/v1/profiles/current/siteProperties  HTTP/1.1
Content-Type: application/json
Authorization: Bearer <access_token>

{
  "siteProperties": [
    {
      "site": {
        "id": "siteUS"
      },
      "properties": {
        "receiveEmail": "yes"
      }
    },
    {
      "site": {
        "id": "siteUK"
      },
      "properties": {
        "receiveEmail": "no"
      }
    }
  ]
}

The response shows the values of the receiveEmail property for all sites on which it has been set. For example, the following is a portion of the response to the above request:

{
  ...
    "items": [
        {
            "site": {
                "id": "siteUK"
            },
            "properties": {
                "receiveEmail": "no"
            }
        },
        {
            "site": {
                "id": "siteUS"
            },
            "properties": {
                "receiveEmail": "yes"
            }
        }
    ],
    "totalNumberOfItems": 2
}

You can also display the current values of site-specific properties using the listSiteProperties endpoint. For example:

GET /ccstore/v1/profiles/current/siteProperties  HTTP/1.1
Content-Type: application/json
Authorization: Bearer <access_token>

The response contains the same data as the updateSiteProperties endpoint response.

Some things to note about using the updateSiteProperties and listSiteProperties endpoints:

Send site-specific properties in webhooks

Several webhooks include profile data for the current shopper in their request bodies. This data includes a sitePropertiesList array that lists the values of site-specific properties such as receiveEmail for each site. These webhooks are:

The following is an example of a sitePropertiesList array listing site-specific property values in a webhook request:

"sitePropertiesList": [
      {
         "site": {"id": "siteDE"},
         "properties": {"receiveEmail": "no"}
      },
      {
         "site": {"id": "siteUS"},
         "properties": {"receiveEmail": "yes"}
      }
   ]

Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices