PromotionMgr is used to access campaigns and promotion
definitions, display active or upcoming promotions in a storefront, and to
calculate and apply promotional discounts to line item containers.
To access campaign and promotion definitions, use methods
getCampaigns(),
getCampaign(String),
getPromotions() and
getPromotion(String).
To display active or upcoming promotions in the storefront, e.g. on product
pages, various methods are provided.
getActivePromotions() returns
a
PromotionPlan with all enabled promotions scheduled for
now.
getActiveCustomerPromotions() returns a
PromotionPlan with
all enabled promotions scheduled for
now and applicable for the
session currency, current customer and active source code.
getUpcomingPromotions(Number) returns a
PromotionPlan with all
promotions that are enabled, not scheduled for
now, but scheduled for
any time between
now and
now + previewTime(hours).
Applying promotions to line item containers is a 3-step process, and
PromotionMgr provides methods supporting each of these steps.
Convenience methods can be used that execute all three steps at once,
or the steps can be executed individually if you need to customize
the output of the steps due to specific business rules.
- Step 1 - calculate active customer promotions: Determine the active
promotions for the session currency, current customer, source code and redeemed coupons.
- Step 2 - calculate applicable discounts: Based on the active promotions
determined in step 1, applicable discounts are calculated.
- Step 3 - apply discounts: applicable discounts are applied to a line
item container by creating price adjustment line items.
The simpliest way to execute steps 1-3 is to use method
applyDiscounts(LineItemCtnr). The method identifies all active
customer promotions, calculates and applies applicable discounts.
Due to specific business rules it might be necessary to manipulate
the set of applicable discounts calculated by the promotion engine
before applying them to the line item container. To implement such a scenario,
you want to use method
getDiscounts(LineItemCtnr), which
identifies all active customer promotions, and calculates and returns
applicable discounts in an instance of
DiscountPlan. The discount
plan contains a description for all applicable discounts for the specified line
item container, and you can remove discounts from it if necessary.
The customized discount plan can then be passed on for application by
using method
applyDiscounts(DiscountPlan).
Due to specific business rules it might be necessary to manipulate the
set of active customer promotions before calculating applicable discounts
from it. For example, you might want to add promotions to the
plan or remove promotions from it.
You want to use method
getActiveCustomerPromotions(), which
identifies all active customer promotions and returns an instance of
PromotionPlan. You can add promotions to the promotion plan
or remove promotions from the plan. The customized promotion plan can then be
passed on to calculate applicable discounts by using method
getDiscounts(LineItemCtnr, PromotionPlan).