SDK Example: Checkout Cart (Fall '19)

Use the example SDK code in this topic to check out a cart.

// Instantiate the input object for checkoutCart to specify parameters
const input = digitalCommerce.checkoutCartInput();
input.catalogCode = "Mobiles"; // use your Catalog Code
input.accountId = "001f200001eSlhe"; // use your account Id
input.cartContextKey = "d5ff11cccd19472ca7c21fa80bc93d2a";

// Used in Checkout process to persist shopping cart content into SF Database
digitalCommerce
  .checkoutCart(input)
  .then(response => {
    Logger.info(
      "Vlocity digital commerce checkout cart for anonymous user: " +
        JSON.stringify(response)
    );
  })
  .catch(error => {
    Logger.info("checkout cart for anonymous user rest call failed" + error);
  });

Possible error conditions:

"checkoutCartInput::getAPIPath() must have catalogCode."

"checkoutCartInput::getAPIPath() must have accountId."

"checkoutCartInput::getAnonymousSiteRestUrl() must have catalogCode."

"checkoutCartInput::getAnonymousSiteRestUrl() must have accountId."

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