Assign a global widget to multiple sites
Global widgets are widgets that are available to all sites in your environment. You can use these widgets to create consistency throughout your sites.
By default, global widgets apply to all sites in your Commerce instance. You may override this default and assign a global widget to be used on only specified sites. To do this, you issue a POST request using the updateSiteAssociations
custom action of the widgetDescriptors
resource and provide a list of sites in a sites
property. For example, the following request updates myGlobalWidget
to execute on siteA
and siteB
only:
POST /ccadmin/v1/widgetDescriptors/myGlobalWidget/updateSiteAssociations {
"sites": ["siteA", "siteB"]
}
To remove site associations, issue a POST request using the same custom action with the sites
property set to null, as displayed in the following example:
POST /ccadmin/v1/widgetDescriptors/myGlobalWidget/updateSiteAssociations
{
"sites": []
}
The following is an example response for a call made using the updateSiteAssociations
custom action, as shown in the following example:
{ "result": true,
"links": [
{
"rel": "self",
"href":
http://localhost:9080/ccadmin/v1/widgetDescriptors/recommendationsTracking_v1/
updateSiteAssociations"
}
]
}
Note that any attempt to update site associations for a widget that is not global results in an error, as will attempting to associate a global widget with a site whose ID does not exist.