Add Fields to the Basket
With basket operations, you can retrieve additional fields as part of their response for the following objects: Order Pricing, OrderItems, OrderAppliedPromotion, and OrderAppliedPromotionItem.
To retrieve additional fields, you need to create fieldsets. You can also set the fields as part of the response.
During a cache-miss, when a new basket is generated, the dc_basket_fs
fieldset field and the default fields that use dc_basket_fs
(Order Pricing, OrderItems, OrderAppliedPromotion, and OrderAppliedPromotionItem) are cached. When creating an actual order checkout or another basket, in the case of a cache miss, those additional fields are synchronized to the newly created Salesforce objects and cached. These object fields, if not read-only, are editable so you can write custom logic to populate those fields during the basket operation. Those fields and values are carried over during cache miss and order creation.
The modifications you’ve made as part of the basket operations can be passed to the order, which recognizes those additional settings.
Once the custom field is stored in the cache, other users can see it and it will be returned in other basket calls if the request matches it.
To create a fieldset:
-
From Setup, in the Quick Find box, enter
Object Manager
. -
Click Object Manager.
-
Click a Salesforce object, for example, Order Pricing.
-
Click Field Sets.
-
Click New.
-
Provide the following information:
-
Field Set Label:
dc_basket_fs
-
Field Set Label:
dc_basket_fs
-
Where is this used?: Type an answer.
-
-
Click Save.
The Layout Editor appears.
-
Drag and drop additional fields as required to the In the Field Set section, then click Save. The header page appears with the dc_basket_fs link under the FIELD LABEL column. The link contains the fields in the fieldset that are returned by the API.
To make any changes to the fields, click dc_basket_fs or the Edit action from the action arrow.
To view custom fields in the Basket API response, pass the custom fields as parameters in the API request. For example,