Broadleaf Microservices
  • v1.0.0-latest-prod

Stale Cart Repricing


Depending on the age of a customer’s cart, the pricing data can become stale - ie the prices today may not be the same as the prices from last week. To avoid the scenario where customers can checkout with out-of-date prices, we introduced the ability to automatically reprice the cart after a time threshold and to validate the pricing at the time of checkout.

Default Implementation Details

The last time the cart was repriced with the latest catalog prices is stored on the Cart in its attribute lastCatalogReprice. This allows us to track the oldest, most "stale", product prices on the cart, so that we can periodically refresh those prices based on a time-to-live property. See broadleaf.cartoperation.service.cart-pricing-time-to-live below.

Stale Cart Pricing Interval

On cart resolution, we check if the cart pricing data’s time to live has been exceeded and is now stale. This is done by checking the cart’s lastCatalogReprice and verifying it against the cartPricingTimeToLive. If we find that the pricing data is stale, then we need to refetch product pricing information from the catalog services and reprice the cart. Additionally, we set the cart’s lastCatalogReprice to the current time. If the pricing data is not stale, then we would continue with resolving the cart using the prices already stored on the cart.

In some cases we want to avoid repricing due to stale cart prices. For example, if the cart has a SUBMITTED status, then checkout has been completed for that cart & prices should not change for the cart. To help enforce these kinds of conditions, we introduced DefaultCartOperationService#shouldRepriceCartIfPricingStale(…​). Feel free to modify the default logic as you see fit.

Stale Cart Checkout Activity

The CartStalePricingValidationActivity serves as the final pricing check, before the customer is allowed to checkout. See Stale Pricing Validation Workflow Activity for more details on how it validates the pricing.

Stale Pricing Cart Messaging

After the cart pricing has been changed, we build a cart alert with information about the new pricing and save it on the cart. This alert can be used on the frontend to notify the customer that their pricing has changed.


CartOperationServiceProperties defines broadleaf.cartoperation.service.cart-pricing-time-to-live.

  • This property specifies the amount of time before the cart’s pricing is considered stale. Once this duration is exceeded, the cart will be fully repriced on its next retrieval. By default, this property is set to 60 minutes.

CartStalePricingValidationActivityProperties defines broadleaf.cartoperation.checkout.activity.validation.cart-stale-pricing.should-reject-lower-price

  • This property declares whether or not to reject the checkout attempt if it’s determined that the latest price for the cart is lower than the cart’s previously known price. By default, this property is set to false.

CartStalePricingValidationActivityProperties defines broadleaf.cartoperation.checkout.activity.validation.cart-stale-pricing.use-real-time-cart-pricing

  • This property declares whether the activity should use real time pricing, or if it should honor the cart pricing time-to-live based on the last catalog reprice. By default, this property is set to false.