Use the example SDK code in this topic to update items in a basket.
// Instantiate the input object for AddToCartInput to specify parameters
let input = Object.assign(
this.digitalCommerceSDK.createUpdateItemsInCartInput(),
{
catalogCode: "Phones",
basketkey: "01tf2000007Rb9JAAS",
basketAction: "updateBasket",
bundleContextKey: "",
lineItemKey: "",
quantity: 2,
customFields: ["customAttribute__c"]
}
);
this.digitalCommerceSDK
.updateItemsInCart(input)
.then(response => {
Logger.info(
"Vlocity digital commerce updateItemsInCart for anonymous user: " +
JSON.stringify(response)
);
})
.catch(error => {
Logger.info("updateItemsInCart action failed: ", error);
});
Possible error conditions:
"UpdateItemsInCart::getAPIPath() must have catalogCode."
"UpdateItemsInCart::getAnonymousSiteRestUrl() must have catalogCode."
"UpdateItemsInCart::getRequestPayload() must have basketAction."
"UpdateItemsInCart::getRequestPayload() must have lineItemKey when basketAction is 'updateBasket'."
"UpdateItemsInCart::getRequestPayload() must have basketkey when basketAction is 'updateBasket'."
"UpdateItemsInCart::getRequestPayload() must have bundleContextKey when basketAction is 'updateBasket'."