Create Basket with BasketAction
The Create Basket with BasketAction API provides the ability to create a basket from items that were added by a user during the configure operation. Also see Post Offer Details with Configuration API.
Use this API to create a basket in the following ways depending on the format of the request body: AddWithNoConfig, AddAfterConfig, and AssetToBasket.
-
returnBasket - This flag indicates whether to return basket information in the AssetToBasket API response. The default value is true, meaning that the AssetToBasket API returns basket information as it did in previous releases, ensuring backward compatibility. If set to false, the Assettobasket API returns only the basket key, and not the complete basket. To use the returnBasket flag, the CacheAPI.SkinnyBasket custom setting must be set to true.
-
includeAttachments - Use this flag to determine whether the API returns attachments URI or not. The default value is false. If includeAttachment is true, the basket API returns a URI to the attachments. If includeAttachment is false or the isloggedin flag is false, the basket API does not return the attachments.
-
When basket items are created, added, modified, or deleted, the basket contents effectivity are validated.
Starting in CME Spring '22, you can update the usage quantity in Basket Operation:
-
Pass the usage quantity as “FieldsTobeUpdated“ for the Usage Quantity field.
-
Pass the Attribute Binding using the respective attribute in the JSON request.
To add the offer without any configured attribute values, pass the following in the request body of the API call:
To add a configured offer, pass the following in the body of the API call:
To change an asset to a basket, format the body of the API call similar to the following:
Use UTC date format for the date-time string: YYYY-MM-DDTHH:MM
Attribute Basket Cache Exclusion
The Fall '20 release includes an Attribute Basket Cache feature. See Attribute Basket Cache Exclusion.
-
Context Eligibility Rules for how known users are supported.
-
Pricing Interface (see Attribute-Based Pricing)
-
Product Validation Interface (see Context Rules Framework and Advanced Rules Framework)
-
For anonymous users, Advanced Rules are supported for Defining Advanced Rules Using Configuration Type and Defining Advanced Rules Using Attribute Configuration Type types only.
-
For known users, Advanced Rules are supported for Defining Advanced Rules Using Configuration Type and Defining Advanced Rules Using Attribute Configuration Type types only.
-
Product Relationships are supported with filters, for example, product A removes Product B.
-
Pricing is supported. However, for pricing, do not use Pricing for Advance Rules. Always use the Custom Pricing Plan, which triggers Attribute-Based Pricing.
-
Catalog should have CatalogCodec populated; spaces are not allowed in CatalogCodec.
-
Products should have ProductCode populated; spaces are not allowed in ProductCode.
-
Promotions should have Codec populated; spaces are not allowed in Codec.
-
Catalog should be present with products and promotions attached to it as records under the CatalogProductRelationship__c object.
-
The Catalog should be attached to a default price list through the DefaultPriceListc field on Catalogc object.
-
Price list entries should exist for all the products attached to the catalog.
-
Create a custom setting called CacheAPIFields with a value of true. CacheAPIFields is not required for CME 103.1.14 and later versions.
-
Batch jobs for the following should have been run ahead of time, thereby populating the cache:
-
Context combinations
-
Offer details
-
Pricing results
-
Digital Commerce API operations create pseudo accounts or orders in the background for basic computations related to respective API calls.
The pseudo accounts or orders is auto deleted based on the CreateCart interface implementation:
-
**DefaultCreateCartImplementation:**During Basket API operations, any pseudo account or order deletion is honored by the custom setting CacheAPI.DeletePseudoRecords.
-
**CreateCartFromPoolImplementation:**During Basket API operations, any pseudo account or order deletion is not honored by the custom setting CacheAPI.DeletePseudoRecords.
For API parameter names and descriptions, see Digital Commerce REST API
Example: Create a new basket and add an offer.
Example: Add an offer to a previously created basket. In the example, the request body is truncated for clarity.
Example: Add a Product to an Empty Basket.
Example: Add a Product to an Existing Basket.
Example: Create Basket with AddAfterConfig. The payload for AddAfterConfig is a response of GetOfferDetails API inside 'productConfigNode'. If you have the response of offer details, you can add it for AddAfterConfig as follows:
Example: Convert Asset to Basket. The following example shows how to convert an asset to a basket. The example assumes you know the asset ID you wish to convert to a basket, and also the account of the user.
Format the request as follows:
To convert more than one asset, you can specify more than one root asset ID in the body of the API call. Separate asset IDs with a comma:
Be sure to note the cartContextKey, the lineItemKey, and the bundleContextKey if you intend to change or configure the offer.