Broadleaf Microservices
  • v1.0.0-latest-prod

Account Cart Approval Workflow

Overview

As of Broadleaf 1.8.0-GA, account cart approval workflow was introduced, which includes:

Submitting a Cart for Approval

As an account member, you can create a cart in the account context, effectively making it an account cart. The general cart operations work the same way, except that the account member cannot complete checkout and must submit the cart for approval.

Note
Account admins can submit their carts for approval as well, however they’re not required to by default

Out of the box, submitting a cart for approval has the following flow:

  • Validate cart can be submitted for approval

  • Change cart status to REQUIRES_APPROVAL

Once the cart is submitted for approval, an account admin can then review and reject or approve the cart. A cart action audit is also created to record this action, see Cart Action Audits for more details

Reviewing Carts as an Account Admin

As an account admin, you can view a list of carts that require approval by sending a request to GET /cart-approval, which will by default retrieve a list of carts that require approval from the current account context as well as its sub-accounts. Optionally, a requestedAccountId parameter can be passed in to retrieve carts from a specific account.

List of Carts Require Approval

Rejecting a Cart

As an admin rejects a cart, the following flow is triggered:

  • Validate cart rejection request

  • Update the cart’s name, status, and attribute

    • The cart name will have a REJECTED {username} {timestamp} pattern

    • The cart status is set to REJECTED

    • The rejection comment is added to Cart’s attributes

  • A cart action audit is created to record this action

  • A cart rejection message event is emitted

Out of the box, the cart rejection comment is added into cart’s attributes with the key of APPROVAL_COMMENT, so that the storefront can display it for the requester:

Rejected Cart

Approving a Cart

Once the admin has reviewed the cart, the cart can then be approved, which by default links the admin to the payment stage of the checkout workflow and can proceed through checkout submission.

The checkout submission process for an account cart is the same for ordinary customer carts, except the system will validate that the user has valid account permission to submit this cart as well as adding a cart action audit.

Cart Action Audits

Cart action audit is a domain used to record the actions taken against a cart. They are created for most B2B account cart actions.

For example, the following is an example cart action audit payload for submitting cart for approval:

  {
    "id": "cart-action-audit-id",
    "action_type": "SUBMIT_FOR_APPROVAL", // (1)
    "cart_id": "cart-id",
    "audit_comment": "Submitting this account cart for approval",
    "data": "{}", // (2)
    "old_status": "IN_PROCESS",
    "new_status": "REQUIRES_APPROVAL",
    "audit_timestamp": "2022-09-26 18:11:42.729",
    "user_id": "user-id",
    "user_type": "BLC_ACCOUNT_MEMBER", // (3)
    "user_email": "member@test.com"
  }
  1. The type of action, see DefaultCartActionTypes

  2. A field for adding customized data

  3. The type of user who performed this action, see DefaultUserTypes

Relevant Endpoints

Path Description

GET /cart-approval

  • Retrieve carts that require approval

  • An optional parameter requestedAccountId can be passed in to retrieve carts from a specific account

POST /cart-approval/{cartId}/submit-for-approval

Submit a cart for approval

POST /cart-approval/{cartId}/reject-cart

Reject a cart that was previously submitted for approval

POST /checkout/{cartId}/process

Process checkout, this endpoint is also used to "approve" an account cart