SDK Example: Save the Cart (Winter '20)

Use the example SDK code in this topic to save the cart by creating an order for the specified basket.

// Instantiate the input object for saveCart to specify parameters
const input = digitalCommerce.createSaveCartInput();
input.email = "YOUR EMAIL ID";
input.catalogCode = "CATALOG CODE";
input.cartContextKey = "CART CONTEXT KEY";

// Invoke saveCart API
digitalCommerce
  .saveCart(input)
  .then(response => {
    Logger.info(
      "Vlocity digital commerce saveCart: " + JSON.stringify(response)
    );
  })
  .catch(error => {
    Logger.info("saveCart apexrest call failed" + error);
  });

Possible error conditions:

"SaveCartInput::getRequestPayload() must have email."

"SaveCartInput::getRequestPayload() must have catalogCode."

"SaveCartInput::getRequestPayload() must have cartContextKey."