Class is located at com.broadleafcommerce.promotion.offer.service.engine.OfferEngineService
.
The OfferEngineService is the entry point for the Offer Engine. This service is used by the OfferEngine endpoints. It handles orchestrating the application of offers to an order and returns the order with populated adjustments. The process of applying the offers consists of the following steps:
Validating the order for key information, such as order items, pricing, etc.
Fetching the applicable candidate offers based on the order information and applied codes.
Building the various permutations of the candidate offers that can be applied to the order.
Weighing the permutations based on total savings and choosing the best permutation of offers to apply.
Applying the adjustments & the prorated adjustments to the order.
Class is located at com.broadleafcommerce.promotion.offer.service.engine.candidate.OfferCandidateService
.
This service determines the offers which could apply based on the provided order and context. This correlates to step 2 in the OfferEngineService flow. The process of finding the candidate offers consists of the following steps:
Fetches all the offers from the database based on the user, codes, and automatically applied offers.
Filters the fetched offers based on
The order and time criteria
The offer & offer code usage information
The user targets
The item qualifiers & targets
Class is located at com.broadleafcommerce.promotion.offer.service.engine.application.OfferApplicationService
.
This service applies the offer permutations to the order and calculates which provides the best discounts. This correlates to step 4 & 5 in the OfferEngineService flow. The process of evaluating the permutations consists of the following steps:
Uses the OrderOfferProcessor
, ItemOfferProcessor
, and FulfillmentGroupProcessor
to score the permutations.
After the permutations have been scored, weighs the results and determines which permutation had the best results.
Applies the adjustments and adjusts the prices based on the best permutation.
Class is located at com.broadleafcommerce.promotion.offer.service.engine.proration.ProrationService
.
This service calculates and applies the prorated order, item, & fulfillment group adjustments. This correlates to step 5 in the OfferEngineService flow. The process of calculating and applying the prorated adjustments consists of the following steps for each type of adjustment:
Determines if the adjustment should be prorated based on the offer type and proration type.
Calculates the amount to prorate proportionally across the items.
Rounds the prorated monetary amounts on the items to ensure that the sum is equal to the total.