@ConsumerType
public interface PromotionHandler
PromotionHandler interface is implemented by services which provide business logic
for Promotions.
Services should define a property PromotionHandler.TYPE with a unique identifier,
which is then used by individual promotions to select a particular PromotionHandler.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TYPE
Service property name.
|
| Modifier and Type | Method and Description |
|---|---|
PriceInfo |
applyCartEntryPromotion(CommerceSession commerceSession,
Promotion promotion,
CommerceSession.CartEntry cartEntry)
Apply a promotion to a cart line item.
|
PriceInfo |
applyOrderPromotion(CommerceSession commerceSession,
Promotion promotion)
Apply a promotion to an order.
|
PriceInfo |
applyShippingPromotion(CommerceSession commerceSession,
Promotion promotion)
Apply a promotion to an order's shipping amount.
|
java.lang.String |
getDescription(SlingHttpServletRequest request,
CommerceSession commerceSession,
Promotion promotion)
Allows a promotion handler to define a custom, author-oriented message for a promotion.
|
java.lang.String |
getMessage(SlingHttpServletRequest request,
CommerceSession commerceSession,
Promotion promotion)
Deprecated.
since 5.6.200; use
getDescription(org.apache.sling.api.SlingHttpServletRequest,
CommerceSession, Promotion) instead. |
java.util.Map<java.lang.Integer,java.lang.String> |
getMessages(SlingHttpServletRequest request,
CommerceSession commerceSession,
Promotion promotion)
Allows a promotion handler to define shopper-oriented messages for a promotion.
|
void |
invalidateCaches()
Informs the promotion handler that something under the promotions root has been edited, and the
handler should invalidate any caches it might be keeping.
|
static final java.lang.String TYPE
PriceInfo applyCartEntryPromotion(CommerceSession commerceSession, Promotion promotion, CommerceSession.CartEntry cartEntry) throws CommerceException
PriceInfo instance
or null if no discount was applied.commerceSession - The commerce session containing the cart.promotion - The Promotion to apply.cartEntry - The cart line item within the session's cart.PriceInfo), or null.CommerceExceptionPriceInfo applyOrderPromotion(CommerceSession commerceSession, Promotion promotion) throws CommerceException
PriceInfo instance or
null if no discount was applied.commerceSession - The commerce session containing the order.promotion - The Promotion to apply.PriceInfo), or null.CommerceExceptionPriceInfo applyShippingPromotion(CommerceSession commerceSession, Promotion promotion) throws CommerceException
PriceInfo instance or null if no discount was applied.commerceSession - The commerce session containing the order.promotion - The Promotion to apply.PriceInfo), or null.CommerceException@Deprecated java.lang.String getMessage(SlingHttpServletRequest request, CommerceSession commerceSession, Promotion promotion) throws CommerceException
getDescription(org.apache.sling.api.SlingHttpServletRequest,
CommerceSession, Promotion) instead.CommerceExceptionjava.lang.String getDescription(SlingHttpServletRequest request, CommerceSession commerceSession, Promotion promotion) throws CommerceException
The info.geometrixx.commons.impl.PerfectPartnerPromotionHandler, for
instance, uses this to list the qualifying pairs of products in the current cart.
request - The current request (used for access-control).commerceSession - The current CommerceSession.promotion - The Promotion.CommerceExceptionjava.util.Map<java.lang.Integer,java.lang.String> getMessages(SlingHttpServletRequest request, CommerceSession commerceSession, Promotion promotion) throws CommerceException
An order-specific promotion should return a single message with a -1 key.
A cart-entry-specific promotion should return its message(s) keyed to the cart entries they apply to.
request - The current request (used for access-control).commerceSession - The current CommerceSession.promotion - The Promotion.-1).CommerceExceptionvoid invalidateCaches()
Copyright © 2010 - 2023 Adobe. All Rights Reserved