How are offer codes applied to an order?
The basic flow when an offer code is applied to an order:
1) -- BroadleafCartController#addOffer
2) ---- OrderServiceImpl#addOfferCode(cart, offerCode, repriceOrder?)
3) -------- Order.getAddedOfferCodes().add(offerCode)
The offer code is added to the Order at this point.
4) -------- OrderServiceImpl#save(order, repriceOrder) -> Returns the Order repriced
When the save is executed and the repriceOrder is "true" then the pricing engine will assess whether the underlying offer (associated by the offercode) qualifies based on the contents of the Order and other rules as specified in the offer. Here's the basic flow from that point:
-- PricingServiceImpl#executePricing(order)<br> ---- blPricingWorkflow<br> ------ blOfferActivity<br> -------- List<Offer> offers = offerService.buildOfferListForOrder(order);<br> -------- order = offerService.applyAndSaveOffersToOrder(offers, order);