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 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 offer
      contextInfo - 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 offer
      contextInfo - 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 offer
      contextInfo - 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 filters
      contextInfo - 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 filters
      contextInfo - 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 customer
      codes - DTO containing relevant codes such as shared 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 order
      contextInfo - context information around sandbox and multitenant state
    • createCandidateOffersFromOffers

      CandidateOffers createCandidateOffersFromOffers(Stream<P> offerSet, EnhancedOrder order)
      Creates a CandidateOffers object by converting the provided offers into their corresponding DTO object based on their DiscountTargetType. The DTO objects are CandidateOrderOffer, CandidateItemOffer, and CandidateFulfillmentGroupOffer
      Parameters:
      offerSet - The set of offers to use to create a CandidateOffers
      order - order context to pupulate the candidate offers on CandidateOffers
      Returns:
      the CandidateOffers built from the provided offer set
    • filterOffersByRequest

      Stream<P> filterOffersByRequest(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order)
      Filter the provided offer set based on information in the given context of the order. This evaluates the EnhancedOrder against the offer's order criteria and Offer.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 the total uses of the offer as well as user uses, while also factoring in Offer.getMaxUsesPerUserFrequency().
      Parameters:
      offerSet - filtered offer set that can apply to the order.
      order - context information around the order
      contextInfo - 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 the Offer.getItemQualifierCriteria(), a quantity of at least ItemCriteriaRule.getNumberOfMatchesRequired() items must match against ItemCriteriaRule.getRule(). In addition, the summed price of these items must be at least Offer.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 the Offer.getItemQualifierCriteria(), a quantity of at least ItemCriteriaRule.getNumberOfMatchesRequired() items must match against ItemCriteriaRule.getRule(). In addition, the summed price of these items must be at least Offer.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 the Offer.getTargetItemCriteria(), a quantity of at least ItemCriteriaRule.getNumberOfMatchesRequired() items must match against ItemCriteriaRule.getRule(). In addition, the summed price of these items must be at least Offer.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. The fulfillment group's details are evaluated against the offer'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 the Offer.getItemQualifierCriteria(), a quantity of at least ItemCriteriaRule.getNumberOfMatchesRequired() items must match against ItemCriteriaRule.getRule(). In addition, the summed price of these items must be at least Offer.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 one EnhancedFulfillmentLineItem must match the offer's ItemCriteriaRule.getRule() with the total quantity matching ItemCriteriaRule.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.