Interface OfferCandidateService<P extends Offer>
- All Known Implementing Classes:
DefaultOfferCandidateService
public interface OfferCandidateService<P extends Offer>
This service determines what offers are candidates for a provided order and context. First we
retrieve all offers that could potentially apply, then we filter those offers down by matching
them against the provided order and context information.
- Author:
- Chad Harchar (charchar)
-
Method Summary
Modifier and TypeMethodDescriptioncreateCandidateOffersFromOffers
(Stream<P> offerSet, EnhancedOrder order) Creates aCandidateOffers
object by converting the providedoffers
into their corresponding DTO object based on theirDiscountTargetType
.<T extends BaseCandidateOffer>
List<T>filterOffersByItemQualifiers
(List<T> offerSet, EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as qualifiers.filterOffersByRequest
(Stream<P> offerSet, EnhancedOrder order) Filter the provided offer set based on information in the given context of the order.filterOffersByTotalUses
(Stream<P> offerSet, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Filter the provided offer set based on thetotal uses
of the offer as well asuser uses
, while also factoring inOffer.getMaxUsesPerUserFrequency()
.getAutomaticAndCodeAndCustomerOffers
(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, com.broadleafcommerce.promotion.offer.client.web.context.Codes codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getAutomaticAndCodeAndCustomerOffers
(Set<String> offerIdsForCodes, Set<String> campaignIdsToFilterOn, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.getCandidateOffers
(EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get the candidate offers for the provided order and context.getCandidateVoucherOffers
(EnhancedOrder order, boolean isPostCheckout, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get the candidate voucher offers for the provided order and context.getOffersForMessaging
(Set<String> offerIds, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve offers that are automatically applied and applicable for marketing messaging.getOffersToFilter
(EnhancedOrder order, Set<String> offerIdsForCodes, Set<String> campaignIdsToFilterOn, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get available offers that need to be filtered to become candidates.getVoucherOffers
(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto> codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve voucher offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.populateOrRemoveByFulfillmentGroupTargets
(List<CandidateFulfillmentGroupOffer> candidateOfferSet, EnhancedOrder order) Filter the provided offer set based on if the provided fulfillment groups of the order match as shipping targets.populateOrRemoveCandidateOffers
(Stream<P> offerSet, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Filter out the provided offer set by matching their configurations against the information on the provided context and order.populateOrRemoveOffersByFulfillmentGroupQualifiers
(List<CandidateFulfillmentGroupOffer> candidateOfferSet, EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as qualifiers.populateOrRemoveOffersByFulfillmentItemQualifiers
(List<CandidateItemOffer> candidateOfferSet, EnhancedOrder order) Filter the provided offer set based on if the fulfillment items of the provided order match as qualifiers.populateOrRemoveOffersByFulfillmentItemTargets
(List<CandidateItemOffer> candidateOfferSet, EnhancedOrder order) Filter the provided offer set based on if the provided fulfillment items of the order match as shipping targets.populateOrRemoveOffersByItemTargets
(List<CandidateItemOffer> candidateOfferSet, EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as targets.
-
Method Details
-
getCandidateOffers
@NonNull CandidateOffers getCandidateOffers(@NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get the candidate offers for the provided order and context.- Parameters:
order
- context information around the offercontextInfo
- context information around sandbox and multitenant state- Returns:
- the list of offers that are candidates to be applied to the provided order.
-
getCandidateVoucherOffers
@NonNull List<CandidateOrderOffer> getCandidateVoucherOffers(@NonNull EnhancedOrder order, boolean isPostCheckout, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get the candidate voucher offers for the provided order and context.- Parameters:
order
- context information around the offercontextInfo
- context information around sandbox and multitenant state- Returns:
- the list of voucher offers that are candidates to be applied to the provided order.
-
getOffersToFilter
@NonNull Stream<P> getOffersToFilter(@NonNull EnhancedOrder order, @NonNull Set<String> offerIdsForCodes, @NonNull Set<String> campaignIdsToFilterOn, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get available offers that need to be filtered to become candidates. This gets offers by user, codes, and automatic offers.- Parameters:
order
- context information around the offercontextInfo
- context information around sandbox and multitenant state- Returns:
- a set of all available offers that need to be filtered down to become candidates.
-
getAutomaticAndCodeAndCustomerOffers
Stream<P> getAutomaticAndCodeAndCustomerOffers(@Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.Codes codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getAutomaticAndCodeAndCustomerOffers
Stream<P> getAutomaticAndCodeAndCustomerOffers(@NonNull Set<String> offerIdsForCodes, @NonNull Set<String> campaignIdsToFilterOn, @Nullable EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.- Parameters:
offerIdsForCodes
- List of relevant offer Ids to filter query on.campaignIdsToFilterOn
- List of relevant campaign Ids to filter query on.order
- the order to determine context information around the customer and other filterscontextInfo
- context information around sandbox and multitenant state- Returns:
- list of offers for automatic consideration or customer specific for the provided customer or that correspond to the provided offer code(s).
-
getOffersForMessaging
List<P> getOffersForMessaging(Set<String> offerIds, @Nullable EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve offers that are automatically applied and applicable for marketing messaging. The implementation will utilize the order to filter the returned offers.- Parameters:
order
- the order to determine context information around the customer and other filterscontextInfo
- context information around sandbox and multitenant state- Returns:
- list of offers for automatic consideration or customer specific for the provided customer or that correspond to the provided offer code(s).
-
getVoucherOffers
Stream<P> getVoucherOffers(@Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull @NonNull List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve voucher offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.- Parameters:
customerContext
- context information around the customercodes
- DTO containing relevant codes such asshared codes
and Campaign tracking IDs.contextInfo
- context information around sandbox and multitenant state- Returns:
- list of voucher offers based on the customer context or the provided offer codes
-
populateOrRemoveCandidateOffers
CandidateOffers populateOrRemoveCandidateOffers(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Filter out the provided offer set by matching their configurations against the information on the provided context and order. For matching offers, associate the relevant item qualifiers and targets that might be used for the offer.- Parameters:
offerSet
- filtered offer set that can apply to the order for the context.order
- context information around the ordercontextInfo
- context information around sandbox and multitenant state
-
createCandidateOffersFromOffers
Creates aCandidateOffers
object by converting the providedoffers
into their corresponding DTO object based on theirDiscountTargetType
. The DTO objects areCandidateOrderOffer
,CandidateItemOffer
, andCandidateFulfillmentGroupOffer
- Parameters:
offerSet
- The set of offers to use to create aCandidateOffers
order
- order context to pupulate the candidate offers onCandidateOffers
- Returns:
- the
CandidateOffers
built from the provided offer set
-
filterOffersByRequest
Filter the provided offer set based on information in the given context of the order. This evaluates theEnhancedOrder
against the offer'sorder criteria
andOffer.getTargetItemCriteria()
.- Parameters:
offerSet
- filtered offer set that can apply to the order for the context.order
- the order with which to evaluate request criteria against- Returns:
-
filterOffersByTotalUses
Stream<P> filterOffersByTotalUses(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Filter the provided offer set based on thetotal uses
of the offer as well asuser uses
, while also factoring inOffer.getMaxUsesPerUserFrequency()
.- Parameters:
offerSet
- filtered offer set that can apply to the order.order
- context information around the ordercontextInfo
- context information around sandbox and multitenant state
-
filterOffersByItemQualifiers
<T extends BaseCandidateOffer> List<T> filterOffersByItemQualifiers(@NonNull List<T> offerSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as qualifiers. For each of theOffer.getItemQualifierCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfQualifierPrices()
.- Parameters:
offerSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByFulfillmentGroupQualifiers
List<CandidateFulfillmentGroupOffer> populateOrRemoveOffersByFulfillmentGroupQualifiers(@NonNull List<CandidateFulfillmentGroupOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as qualifiers. For each of theOffer.getItemQualifierCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfQualifierPrices()
.- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByItemTargets
List<CandidateItemOffer> populateOrRemoveOffersByItemTargets(@NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as targets. For each of theOffer.getTargetItemCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfTargetPrices()
.- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveByFulfillmentGroupTargets
List<CandidateFulfillmentGroupOffer> populateOrRemoveByFulfillmentGroupTargets(@NonNull List<CandidateFulfillmentGroupOffer> candidateOfferSet, EnhancedOrder order) Filter the provided offer set based on if the provided fulfillment groups of the order match as shipping targets. Thefulfillment group's
details are evaluated against theoffer's fulfillment group criteria
.- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByFulfillmentItemQualifiers
List<CandidateItemOffer> populateOrRemoveOffersByFulfillmentItemQualifiers(@NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the fulfillment items of the provided order match as qualifiers. For each of theOffer.getItemQualifierCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfQualifierPrices()
.- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByFulfillmentItemTargets
List<CandidateItemOffer> populateOrRemoveOffersByFulfillmentItemTargets(@NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the provided fulfillment items of the order match as shipping targets. At least oneEnhancedFulfillmentLineItem
must match the offer'sItemCriteriaRule.getRule()
with the total quantity matchingItemCriteriaRule.getNumberOfMatchesRequired()
.- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-