Broadleaf Microservices



Service that handles pricing operations on a cart.

Default Implementation Details

This workflow is as follows:

  1. Initialize PriceCartRequest

  2. Clear current pricing information from the cart

    • Clears all totals on the cart

    • Resets the currency and locale

    • Clears all totals on FulfillmentGroups including CSR price overrides

    • Clears all totals on CartItems including CSR price overrides

  3. Price cart items via PricingProvider

  4. Calculate each item’s subtotal

  5. Record whether each item was priced

    1. If the item was not priced, a ConfigError is added to its globalConfigErrors with failure type PRICE_UNAVAILABLE and a localized message, cartItem.validationError.noPriceFoundForItem,

    2. Then the cart item is wrapped in a CartItemValidationException

    3. Which is then thrown, to be handled by the the original caller (e.g., the frontend client)

  6. Apply order and order item adjustments (a.k.a., offers or discounts) via OfferProvider

    • This is done before fulfillment pricing since fulfillment pricing can be dependent on merchandise pricing, particularly whether discounts can be applied like "free shipping on orders of $50 or more"

  7. Calculate fulfillment pricing

  8. Apply fulfillment and fulfillment item adjustments via OfferProvider

    • The OfferProvider takes an argument determining whether order and order item adjustments should be calculated, allowing this second call to isolate fulfillment adjustment calculations

  9. Calculate the cart totals

  10. Mark the cart as priced

  11. Persist if requested


CartOperationServiceProperties defines broadleaf.cartoperation.service.calculateProratedFulfillmentPricing. This property determines whether order-level adjustments (a.k.a, offers or discounts) should be prorated to each order item, primarily for tax purposes. Thus, if an order has a $20 discount and 5 items, then each item gets a $4 discount attributed to it. Default is true.

Calculating Totals

Totals are calculated in the following order:

  1. Item adjustments (a.k.a, discounts) totals

  2. Item totals

    • This is (unit-price x quantity) - adjustments total

  3. Cart Subtotal: Without adjustments, fulfillment, or taxes

    • This is the sum of the cart item totals without their adjustments

  4. Cart adjustments total

    • Includes the sum of all cart item adjustments

    • Without any fulfillment adjustments, this is included in fulfillment total already

  5. Fulfillment total

    • Includes fulfillment and fulfillment item costs less adjustments

  6. Tax total

  7. Cart total

    • This is subtotal + fulfillment total + tax total - adjustments total

Finally, by default, the active payment is also updated so that its amount matches the cart’s total.

These calculations are primarily handled by CartTotalsCalculator, but tax is handled by the [TaxService].