24 Work with Carts that are Shared Across Multiple Sites

When your environment contains multiple sites, you can configure your instance to share carts among them.

Sharing carts across multiple OSF sites allows your customers to put items into a cart from Site A, as well as from Site B. Shoppers can navigate among sites using a single login and can check out an order that contains items from either site. Shopping carts can be shared across all sites, or a subset of sites.

Note: Shared carts apply only in OSF environments.

For example, if you have a site named MyCompanyOne and another site name MyCompanyTwo, you can allow your shoppers to access both sites without logging off of one site and onto the other site. The shopper can also put an item from MyCompanyOne and an item from MyCompanyTwo into their cart and check out, combining items from two separate sites into a single order.

Customer service representatives can use the Agent Console to assist shoppers with orders that contain items from multiple sites. This allows Agents to perform returns, exchanges and appeasements for these items. Note that to support this on the Agent Console, the Agent should use the On Behalf functionality to work with the order. Refer to the Understand shopping on behalf of a shopper section for additional information.

Understand how carts are shared

Carts can be shared across multiple sites, in both consumer and account-based environments, by using the Admin API to create cart sharing groups, which use the sites' ID to identify and include specific sites. When sites are included in a cart sharing group, shoppers can use a single cart among all included sites.

Carts that are shared in multiple site environments work for both registered and anonymous shoppers if the environment uses a single top-level domain. For example, if your domain is www.example.com and you also have another site with the same domain and context root, such as www.example.com/MyCompany, or www.MyCompany.example.com, both registered and anonymous shoppers' carts can be shared among sites. However, only registered shoppers' carts can be shared among sites that do not use the same domain or sub-domain, such as www.mycompanyone.com and www.mycompanytwo.com. For detailed information on configuring and using domains, refer to Configure Storefront SSO.

The site that the shopper is currently on determines the language, currency, price group and catalog that is displayed. This means that if the shopper changes from SiteA to SiteB, the language, currency, price group and catalogs that are displayed may change, based upon how they are set on SiteB.

The site on which the shopper checks out determines the tax configuration and the payment gateway used in the order. Tax configurations do not change based upon the shopper's current site, unless your site computes and displays tax values prior to checkout. They are set only when the shopper initiates the checkout process.

Note that there are two site properties that are used on the order. These are createSiteId and siteId. The createSiteId property is set to whichever site the shopper was on when the first item was added, and is not updated. The siteId property is set every time an item is added to the cart, and again when the order is submitted.

Understand how prices work with carts shared among multiple sites

When you add sites to a cart sharing group, you must ensure that each product for each catalog used on the sites contains, at the minimum, a list price. This means that for every site in the cart sharing group, there must be list prices for all of the products within all of the catalogs used by all of the sites. If a price does not exist, a pricing error will occur. Should you choose to, you can add a sale price across all of the catalogs for sites that share a cart, which allows your shoppers to receive the sales price during checkout. To prevent shopper confusion, it is best to use the same price for products sold across different sites; the price that the shopper pays is based upon where the order was last priced, not upon the site where the item was added to their cart. For example, if you have the same t-shirt on both SiteA and SiteB, but the t-shirt of SiteA costs $25 and the t-shirt on SiteB costs $50, if the shopper checks out on SiteB, the t-shirt will be priced at $50. If the shopper checks out on SiteA, the t-shirt will be $25. This could confuse and discourage your shoppers.

If a shopper adds the same item from two different sites to their cart, the products will show up as different line items within the order. For example, if a shopper puts White Shirt with Ruffles from MyCompanyOne into their cart, and then puts White Shirt with Ruffles from MyCompanyTwo into their cart, their order will display two different line items that contain White Shirt with Ruffles. Additionally, if each site has a different price for the shirt, the price of the White Shirt with Ruffles will come from the site where the order was last priced. For additional information on working with prices, refer to Assign Catalogs and Price Groups to Shoppers.

When a shopper uses shared carts within a multiple site environment, the currency matches the current site every time that the order is priced. For example, if a shopper adds an item to their cart on SiteA, which uses US Dollars, and then adds items to their cart from SiteB, which uses Pesos, both items will be priced in Pesos whenever the shopper views their cart on SiteB. The system does not retain currency context as the shopper moves from one site to the other.

Working with shared carts has several implications on different aspects of your storefront. The following are some things you should keep in mind when configuring shared carts.

Security and carts shared among multiple sites

Your shoppers do not need to re-enter credentials when moving from site to site or when adding items to their cart. For information on setting security for shoppers, refer to Implement Storefront Single Sign-On. Note for GDPR: Although it appears that shopper information is shared across multiple sites, there is no change to the physical location of a shopper's data nor the organizations that have access to that data. For information on configuring GDPR, refer to Manage the Use of Personal Data.

Understand inventory and carts shared among multiple sites

Inventory is decremented from the site that the shopper was on when the item was added to the cart. Buy Online Pay In Store inventory is obtained from locations set in the locationId property of the InStorePickUpShipping Group. For information on configuring inventory settings, refer to Manage Multiple Inventory Locations.

Work with promotions in carts shared among multiple sites

Site-specific promotions, as well as promotions that apply to any of the sites that share a cart are available to shoppers. You can create item, order and shipping promotions across all sites within a cart sharing group. Additionally, you can create an item promotion that is valid on only a single site within the cart sharing group.

Review order history in carts shared among multiple sites

Whenever a shopper views their order history for sites that are part of the cart sharing group, orders for all of the sites within the group display.

Understand webhooks in carts shared among multiple sites

All order and commerce item site IDs are exposed in order-related webhooks. For information on working with webhooks, refer to Use Webhooks.

Work with cart sharing groups

Cart sharing groups allow you to determine how shopping carts are shared across sites on a single instance of Commerce. Note that all aspects of creating, updating or removing cart sharing groups must be done through the API. For additional information, refer to Use the APIs on instances running multiple sites.

Cart sharing groups are site groups that have been designated as sharing a resource, specifically shopping carts. Site groups that are identified as cart sharing groups use a Boolean property in their response and request payloads. This property indicates if the site group is a cart sharing group. Note that a site must exist before it can be added to a site group or a cart sharing group. Sites can be a member of only one cart sharing group. Because sites are publishable assets, site groups are also publishable. However, a site group cannot be published without its member sites also being published.

To work with cart sharing groups, use the siteGroups API. For detailed information on this API, refer to the REST API documentation.

Create a cart sharing group

To create a cart sharing group issue a POST command in the siteGroups API. The following example creates a cart sharing group that contains three sites:
POST  /ccadmin/v1/siteGroups

{
  "id": "cartGroupUSSites",
  "displayName": "Cart sharing group for US Sites",
  "sites":[ {"id": "siteUSSouth"}, {"id": "siteUSWest"}, {"id": siteUSEast} ],
  "sharedCart" : true
}
The request uses the following properties:
Property Description
sites (required) All elements in the site array must contain a site id property. Note that sites must exist before they can be added to a group. This property is an array of sites that make up the cart sharing group.
id (optional) When creating a cart sharing group, the id property is optional.
displayName (optional) If you do not provide a displayName, the group's displayName is set to the group's ID.
sharedCart (optional) This property, when set to true, indicates that the site group is a cart sharing group. This property defaults to false.
The response to this request would be:
POST  /ccadmin/v1/siteGroups

{
  "id": "cartGroupUSSites",
  "displayName": "Cart sharing group for US Sites",
  "sites":[
    {"id": siteUSSouth, "name": "Southern US site"}
    {"id": siteUSWest, "name": "Western US site"}
    {"id": siteUSEast, "name": "Eastern US site"}
  ],
  "sharedCart" : true
}

Update a cart sharing group

You can update a cart sharing group by issuing a PUT command such as:
PUT  /ccadmin/v1/siteGroups/{id}

Use the site group's ID to indicate which group to update.

The request and the response are the same as when creating the cart sharing group. However, note the following:
  • If you specify the id property in the request body, it is ignored.
  • If you omit a property from the request body, the old value of the property is retained.
  • When a sites array is presented in the request body, the new value totally replaces the old value. Incremental additions and deletions within the site array are not supported.
  • If the sharedCart property in the request is different than the group's old settings, the group changes from a site group to a cart sharing group, and vice versa.

Delete a cart sharing group

You can delete a cart sharing group by issuing a DELETE command using the following syntax:
DELETE  /ccadmin/v1/siteGroups/{id}

Note that a group cannot be deleted if it contains any sites.

Get cart sharing groups

You can get a single cart sharing group by issuing a GET command using the following syntax:
GET  /ccadmin/v1/siteGroups/{id}
You can get a collection of cart sharing groups by issuing a GET command using the following syntax:
GET  /ccadmin/v1/siteGroups/

The get collection endpoint supports standard optional query parameters, such as offset and limits. It also supports the q query parameter that allows you to filter site groups by the dislayName, id and sites properties.