Determines which promotions (Reward objects used for checkout/cart offers) a purchaser or cart currently qualifies for, and resolves a promotion's stored configuration - entry codes, discount and gift settings, quiz and upload options - from the reward.properties file held against the reward. Consumed by cart pricing, checkout rules and points rule evaluation to check promotion eligibility and to read a promotion's details as a PromotionBean before applying its discount or gift behaviour.


Methods

promotions() · promotions(Boolean open, Date now) · availablePromotions(Date now, BaseEntity customer) · availablePromotions(Date now, BaseEntity customer, Boolean open) · isElligbleParticipant(BaseEntity participant, Reward promotion) · matchesParticipantSelector(Reward promo, BaseEntity entity) · matchesParticipantSelector(List<KSelectorItem> sels, Organisation entity) · participantSelectors(Reward promo) · isMatchingPromoCode(String code, Reward promotion) · getPromoEntryCodes(Reward reward) · promotionDetails(Reward reward) · loadRewardProps(Reward reward) · loadRewardProps(DirectoryNode rewardNode) · getTerms(Reward reward) · qualifiesForCheckoutPromotion(PromotionBean promoDetails, Cart cart) · countItemsForCheckoutPromotion(PromotionBean promoDetails, Cart cart) · calcFreeGiftQuantity(PromotionBean promoDetails, Cart cart)

promotions()

Returns: List<Reward>

All promotions defined for the current organisation, regardless of whether they are open or finished.

promotions(Boolean open, Date now)

Returns: PromotionsList

Finds the promotions defined for the current organisation, optionally filtered by whether they are finished as at the given date.

ParameterDescription
openif null, all promotions are returned; if true, only promotions not finished as at now are returned; if false, only promotions finished as at now are returned
nowthe date to evaluate the open filter against

availablePromotions(Date now, BaseEntity customer)

Returns: PromotionsList

Finds the currently open promotions the given customer is eligible to participate in. Equivalent to calling the 3-argument overload with open set to true.

ParameterDescription
nowthe date used to evaluate whether a promotion is open
customerthe profile or organisation to check eligibility for

availablePromotions(Date now, BaseEntity customer, Boolean open)

Returns: PromotionsList

Finds the promotions defined for the current organisation that match the given date and eligibility criteria. When customer is null, only promotions with no organisation criteria and open group/org membership are returned; otherwise a promotion is included only if the customer is an eligible participant, as determined by isElligbleParticipant.

ParameterDescription
nowthe date used to evaluate the open filter
customerthe profile or organisation to check eligibility for, or null to check only date and having no organisation criteria
openif null, promotions are not filtered by date; if true, only promotions open as at now are included; if false, only promotions not open as at now are included

isElligbleParticipant(BaseEntity participant, Reward promotion)

Returns: boolean

Determines whether a profile or organisation is eligible to participate in a promotion. A profile is eligible if the promotion's group criteria include the profile and, when the promotion has organisation criteria, one of the profile's primary organisations matches the promotion's organisation type and participant selectors. An organisation is eligible if the promotion's organisation criteria include it directly.

ParameterDescription
participantthe profile or organisation to check
promotionthe promotion to check eligibility for

matchesParticipantSelector(Reward promo, BaseEntity entity)

Returns: boolean

Checks whether an organisation matches a promotion's configured participant selectors. Always returns false for a profile entity, since participant selectors apply only to organisations.

ParameterDescription
promothe promotion whose participant selectors are checked
entitythe organisation to check, or a profile, which never matches

matchesParticipantSelector(List<KSelectorItem> sels, Organisation entity)

Returns: boolean

Checks whether an organisation falls within one of a set of organisation selectors. An empty selector list matches everything.

ParameterDescription
selsthe parsed participant selectors to check against
entitythe organisation to check

participantSelectors(Reward promo)

Returns: List<KSelectorItem>

Parses a promotion's raw participant selector configuration into structured selector items.

ParameterDescription
promothe promotion to read participant selectors from

isMatchingPromoCode(String code, Reward promotion)

Returns: boolean

Checks whether the given code matches one of the promotion's configured entry codes.

ParameterDescription
codethe code entered by the user
promotionthe promotion whose entry codes are checked

getPromoEntryCodes(Reward reward)

Returns: String

Reads the raw, delimiter-separated entry codes configured for a promotion, if a code is required to activate it.

ParameterDescription
rewardthe promotion to read entry codes from

promotionDetails(Reward reward)

Returns: PromotionBean

Loads a promotion's configured details, read from the reward.properties file stored against the reward.

ParameterDescription
rewardthe promotion to load details for

loadRewardProps(Reward reward)

Returns: Properties

Loads the raw reward.properties file for a promotion, creating its rewards directory if it does not already exist.

ParameterDescription
rewardthe promotion to load properties for

loadRewardProps(DirectoryNode rewardNode)

Returns: Properties

Loads the reward.properties file from a reward's directory node.

ParameterDescription
rewardNodethe directory node holding the promotion's files, or null

getTerms(Reward reward)

Returns: String

Reads the terms and conditions HTML file stored against a promotion.

ParameterDescription
rewardthe promotion to read terms for

qualifiesForCheckoutPromotion(PromotionBean promoDetails, Cart cart)

Returns: boolean

Checks whether a cart contains enough qualifying items for a checkout promotion to apply.

ParameterDescription
promoDetailsthe promotion's details, including its qualifying product categories
cartthe cart to check

countItemsForCheckoutPromotion(PromotionBean promoDetails, Cart cart)

Returns: BigDecimal

Counts the quantity of items in a cart that qualify for a checkout promotion. If the promotion has no qualifying categories configured, the cart's total item quantity is returned; otherwise only items in one of the qualifying categories are counted.

ParameterDescription
promoDetailsthe promotion's details, including its qualifying product categories
cartthe cart to count qualifying items in

calcFreeGiftQuantity(PromotionBean promoDetails, Cart cart)

Returns: BigDecimal

Calculates the quantity of a free gift a cart has earned under a checkout promotion, based on the quantity of qualifying items in the cart, capped at the promotion's configured maximum gift quantity.

ParameterDescription
promoDetailsthe promotion's details, including its qualifying categories and maximum gift quantity
cartthe cart to calculate the free gift quantity for
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.