java.lang.Object
com.broadleafcommerce.promotion.offer.domain.Offer
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.money.CurrencyConsumer, ActiveDateEntity, Serializable, Comparable<Offer>, javax.money.CurrencySupplier

public class Offer extends Object implements Serializable, Comparable<Offer>, com.broadleafcommerce.data.tracking.core.ContextStateAware, ActiveDateEntity, javax.money.CurrencySupplier, com.broadleafcommerce.money.CurrencyConsumer
An Offer encapsulates information required to provide specialized discount pricing for orders, order items, or related entities This includes not just the discount amount but also important factors such as whether the discount is a percent off, amount off, or fixed price type and whether it should be applied immediately or provided as future credit to the user. Furthermore, an Offer allows for complex rules for determining what qualifies an order or item to receive its discount, whether multiple offers can be applied to the same target, how many times or how frequently an offer can be used.
Author:
Nathan Moore (nathanmoore).
See Also:
  • Field Details

    • maxUsesPerUserStrategy

      protected String maxUsesPerUserStrategy
      Enum that allows implementations to vary how user max uses will be interpreted. By default the strategy will be UserMaxUsesStrategyType.CUSTOMER.
    • roundDiscountsByItemUnit

      public Boolean roundDiscountsByItemUnit
      For testing. Future enhancement to allow population via a JpaOrder property.
  • Constructor Details

    • Offer

      public Offer()
  • Method Details

    • getAttribute

      public <T> T getAttribute(String name)
    • isFutureCredit

      public boolean isFutureCredit()
      Future credit means that the associated adjustment will be discounted at a later time to the user via a credit. It is up to the implementor to decide how to achieve this.
      See Also:
    • getFriendlyOfferType

      public String getFriendlyOfferType()
      Returns:
      Friendly type of this offer combining the Discount.getMethodType() and Discount.getTargetType()
    • getFriendlyDiscountAmount

      public String getFriendlyDiscountAmount()
      Returns:
      Friendly discount amount string using the Discount.getAmount() or, if tiered, the first tier's DiscountTier.amount with a "%" appended if the discount method is DiscountMethodType.PERCENT_OFF.
    • isCombinable

      public boolean isCombinable()
      Returns:
    • isCombinableWithOtherTypes

      public boolean isCombinableWithOtherTypes()
    • isTotalitarian

      public boolean isTotalitarian()
    • getItemRestrictionType

      public String getItemRestrictionType(boolean isForQualifier)
      Translates the combination of qualifiersCanBeTargets and qualifiersCanBeQualifiers into an enum value.
      Parameters:
      isForQualifier - whether the item in question is a qualifier instead of a target
      Returns:
      the item restriction type (e.g., ItemRestrictionType) for the item type (e.g., target or qualifier)
      See Also:
    • compareTo

      public int compareTo(Offer that)
      Compares priorities. Null is less than non-null.
      Specified by:
      compareTo in interface Comparable<Offer>
      Parameters:
      that - Offer to which we are comparing.
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • getBaseDiscountMethodType

      protected Optional<String> getBaseDiscountMethodType()
      Returns:
      the Discount.getMethodType() of this offer or, if tiered, the first tier's DiscountTier.methodType
    • getBaseDiscountAmount

      protected BigDecimal getBaseDiscountAmount()
      Returns:
      the Discount.getAmount() of this offer or, if tiered, the first tier's DiscountTier.amount
    • getOfferTypeOnlyTarget

      protected String getOfferTypeOnlyTarget()
    • getOfferTypOnlyMethod

      protected String getOfferTypOnlyMethod()
    • cleanMethodType

      protected String cleanMethodType(String methodType)
    • hasLimitedUsesPerOrder

      public boolean hasLimitedUsesPerOrder()
      Whether this Offer has limited uses per order.
      Returns:
      Whether this Offer has limited uses per order.
    • populate

      public com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef populate(com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offerRef)
      Populate an OfferRef with the given information on this Offer.
      Parameters:
      offerRef - the OfferRef to populate with this Offer.
      Returns:
      the populated OfferRef
    • hasItemQualifierCriteriaRules

      public boolean hasItemQualifierCriteriaRules()
      Whether this offer has item qualifier rules to be matched.
      Returns:
      Whether this offer has item qualifier rules to be matched.
    • hasTargetItemCriteriaRules

      public boolean hasTargetItemCriteriaRules()
      Whether this offer has target item rules to be matched.
      Returns:
      Whether this offer has target item rules to be matched.
    • getOfferDiscountStrategy

      public String getOfferDiscountStrategy()
      Returns the discount strategy. See OfferDiscountStrategy.

      For backwards compatibility (offers created in 1.4 and earlier), if the deprecated isTieredDiscount() is true, this returns OfferDiscountStrategy.TIERED_ITEM_QTY. If no offerDiscountStrategy is set and this isn't a tiered discount, OfferDiscountStrategy.STANDARD is assumed.

      Returns:
      The discount strategy.
    • isTieredOffer

      public boolean isTieredOffer()
    • getPriorityForComparisons

      public Long getPriorityForComparisons()
    • isApplyDiscountToAllTargets

      public boolean isApplyDiscountToAllTargets()
    • isTieredDiscount

      @Deprecated public boolean isTieredDiscount()
      Deprecated.
      since 1.6. Use isTieredOffer()
      Returns:
      Is this a tiered discount?
    • getExcludeDiscountedItemsFromTotals

      public boolean getExcludeDiscountedItemsFromTotals()
    • getApplyRemainderToFulfillment

      public boolean getApplyRemainderToFulfillment()
    • getGeneralMaxUsageStatus

      public String getGeneralMaxUsageStatus()
    • getId

      public String getId()
      The context ID of the offer.
      Returns:
      the context ID of the offer.
    • getExternalId

      public String getExternalId()
      This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
      Returns:
      an external ID
    • getName

      public String getName()
      Display name for this offer.
      Returns:
      the name of this offer
    • getDescription

      public String getDescription()
      Description of this offer.
      Returns:
      Description of this offer.
    • getCartLabel

      public String getCartLabel()
      A label for this offer typically used by the storefront.
      Returns:
      A label for this offer typically used by the storefront.
    • getDiscountTiers

      public List<DiscountTier> getDiscountTiers()
      List of discount tiers determining the discount applied with this offer.
      Returns:
      List of discount tiers for this offer
      See Also:
    • getDiscount

      public Discount getDiscount()

      Basic discount information for this offer.

      If tieredDiscount is true, then Discount.getMethodType() and Discount.getAmount() are overridden by the same fields in the tiers (see DiscountTier).

      Returns:
      The Discount for this offer
    • getCurrency

      @Nullable public javax.money.CurrencyUnit getCurrency()
      The currency that an EnhancedOrder.getCurrency() must be for this offer to apply.

      This is typically used for offers where currency matters more. For example, an offer with Discount.getAmount() of 5 has different values in USD and EUR.

      Specified by:
      getCurrency in interface javax.money.CurrencySupplier
    • getPriority

      public Long getPriority()
      When multiple offers match a context, the offer with the higher priority is applied first, where smaller integer values represent higher priorities. When used for comparisons, null should treated as lowest priority per getPriorityForComparisons().
      Returns:
      the relative precedence of this offer vs others that can also be applied in the same context
    • getActiveStartDate

      public Instant getActiveStartDate()
      Defines the beginning time for which this offer is active.
      Specified by:
      getActiveStartDate in interface ActiveDateEntity
      Returns:
      The date after which this offer is active
    • getActiveEndDate

      public Instant getActiveEndDate()
      Defines the ending time for which this offer is active. Must be later than activeStartDate or null which indicates that this offer applies indefinitely.
      Specified by:
      getActiveEndDate in interface ActiveDateEntity
      Returns:
      The date before which this offer is active
    • getCombinabilityOverrides

      public Set<CombinabilityOverride> getCombinabilityOverrides()
      The CombinabilityOverrides that override how this offer combines with other offers.
      Returns:
      the combinabilityOverrides for this offer
      See Also:
    • getOfferCodes

      public Set<OfferCode> getOfferCodes()
      The shared codes that can be used to retrieve this offer. These codes would be used in situations where this offer is not automatically considered (meaning automaticallyConsidered is false}
      Returns:
      the codes that can be used to retrieve this offer
    • getCampaignTrackingIds

      public Set<String> getCampaignTrackingIds()
      The tracking identifiers of the campaigns of which this offer is a part. See com.broadleafcommerce.promotion.campaign.domain.Campaign#id
      Returns:
      The tracking codes of the campaigns of which this offer is a part
    • getSegment

      public String getSegment()
      The segments to which this offer can apply. Segments are useful for systems that create offers for portions of the cart. For example, a vendor might have 10% off all items in the "vendor A" segment. Another example, is a site that uses a shared cart for 3 different store concepts (aka banners). A value of null, empty or "ANY" is the most common usage and means that this offer can apply to any qualifying part of the order. This field qualifies items using the EnhancedLineItem.getSegment() property.
      Returns:
      The segment of the order that this offer applies to
    • getCombinabilityType

      public String getCombinabilityType()
      Determines whether this offer can be combined with other offers. Default is CombinabilityType.ANY, meaning this offer is combinable with any other offer.
      Returns:
      the type of combinability this offer has with other offers
      See Also:
    • isStackable

      public boolean isStackable()
      Determines whether this offer can be stacked on top of other offers of the same type. This is different than CombinabilityType.ANY which indicates tha two offers can coexist in the same order but doesn't allow them to apply to the same target. For example, consider two offers where the first is "10% off jeans" and the second is "5% off clothing". If these are not stackable, then any jeans in the order will get 10% off while other clothing will get 5% off. If they are stackable, the jeans will get both offers and be 15% off.
      Returns:
      the type of combinability this offer has with other offers
      See Also:
    • isAutomaticallyConsidered

      public boolean isAutomaticallyConsidered()

      Determines whether this offer should be considered to be applied without needing any shared codes (or some other, similar constraint). Default is false.

      Setting to true does not guarantee that the offer will be applied. All criteria and rules associated with this offer must still be met (e.g., targetItemCriteria, itemQualifierCriteria, orderCriteria, and timeCriteria).
      Returns:
      whether this offer should be considered to be applied without needing any shared codes (or some other, similar constraint)
    • isPreferCartBundling

      public boolean isPreferCartBundling()
      This property provides a hint to the front-end application to perform grouping for items that share the same discount. The intended use is for offers with multiple targets such as a "bundle offer" - that is setup as Buy 2 for $10" As the offer engine supports the concept of an item being part of more than one bundle, applications will need to make decisions on how to interpret this flag.
      Returns:
      Whether applications should attempt to group items that share this discount
    • isDistributeOfferAmountToTargets

      public boolean isDistributeOfferAmountToTargets()
      This property impacts the way that items share the same discount. The intended use is for offers with multiple targets such as a "bundle offer" - that is setup as Buy 2 for $10"
      Returns:
      Whether the amount property should be distributed to targets
    • isRequiresRelatedTargetAndQualifiers

      public boolean isRequiresRelatedTargetAndQualifiers()
      Determines whether a qualifier must be matched to targets that are in its lineage, that is, targets must either be descended from or an ancestor of a qualifier. This is discovered by repeatedly calling the qualifier's EnhancedOrderLineItem.getParent() to find the root ancestor; then, from the root, repeatedly calling EnhancedOrderLineItem.getChildren() to find if a potential order item is a descendant thereof, that is, in the same lineage as the qualifier.
      Returns:
      whether a qualifier must be matched to targets that are in its lineage
    • getItemQualifierCriteria

      public ItemCriteria getItemQualifierCriteria()
      Info related to determining what items are required so that an order or other items qualify to receive this offer's discount. If these items should not just qualify but also receive the discount, then set Discount.getProrationType() to ProrationType.TARGET_AND_QUALIFIER.
      Returns:
      Info related to determining how an entity can qualify to receive this offer.
      See Also:
    • getMinTotalOfQualifierPrices

      public javax.money.MonetaryAmount getMinTotalOfQualifierPrices()
      Determines the price subtotal threshold that all qualifying items must reach in addition to itemQualifierCriteria in order to qualify an order items to receive this offer's discount. That is, the system will find all qualifying items (based on itemQualifierCriteria) for the given offer and sum their prices before any discounts are applied. If that sum reaches or exceeds this minTotalOfQualifierPrices, then the targets of the offer "qualify" to receive the discount.
      Returns:
      the price subtotal threshold that all qualifying items must reach in addition to itemQualifierCriteria in order to qualify an order items to receive this offer's discount.
    • isQualifiersCanBeQualifiers

      public boolean isQualifiersCanBeQualifiers()
      Determines whether items that qualify an order to receive this offer's discount can also be used as qualifiers for other offers of the same type (e.g., Order, Order Item, Fulfillment). For example, if an offer requires that an order contains a "red t-shirt" item in order to qualify for a 10% discount and another offer also requires that a "red t-shirt" be present to qualify for a 10% shipping discount, then this field determines whether that red t-shirt can be used by both offers to qualify the order for both 10% off the subtotal and 10% off shipping or if only the better offer can be applied. Default is false: A single qualifier cannot cause more than 1 offer to be applied.
      Returns:
      whether items that qualify an order to receive this offer's discount can also be used as qualifiers by other offers.
    • isQualifiersCanBeTargets

      public boolean isQualifiersCanBeTargets()
      Determines whether items that qualify an order to receive this offer's discount can also receive discounts from other offers of the same type (e.g., Order, Order Item, Fulfillment). For example, if this offer requires that an order contains a "red t-shirt" be present to qualify for a 10% discount on another item (think BOGO) and another offer targets that same "red t-shirt" for a 10% discount (rather than as a qualifier), then this field determines whether that red t-shirt can both qualify the another item for a 10% discount and itself receive a 10% discount or just 1 can be discounted. Default is false: A qualifier cannot also receive an individual discount.
      Returns:
      Determines whether items that qualify an order to receive this offer's discount can also receive discounts from other offers.
    • getTargetItemCriteria

      public ItemCriteria getTargetItemCriteria()
      Info related to determining what order items can receive this offer's discount.
      Returns:
      Info related to determining what items can receive this offer's discount.
      See Also:
    • getMinTotalOfTargetPrices

      public javax.money.MonetaryAmount getMinTotalOfTargetPrices()
      Determines the price subtotal threshold that all targeted items must reach in addition to targetItemCriteria in order to receive this offer's discount. That is, the system will find all targeted items in an order and sum their prices before any discounts are applied. If the sum reaches or exceeds this minTotalOfTargetPrices, then the targets can receive the discount.
      Returns:
      the price subtotal threshold that all targeted items must reach in addition to targetItemCriteria in order to receive this offer's discount.
    • getMaxUses

      public int getMaxUses()
      Determines the maximum number of times this offer can be used. A value of 0 indicates unlimited usage. Default is 0.
      Returns:
      the maximum number of times this offer can be used.
    • getMaxTotalDiscount

      public javax.money.MonetaryAmount getMaxTotalDiscount()
      Determines the maximum savings this offer is valid for. For example, this offer can discount a total of $5000 before it is considered unavailable for further usage. A value of 0 indicates unlimited usage. Default is 0.
      Returns:
      the maximum savings this offer is valid for.
    • getMaxUsesPerOrder

      public int getMaxUsesPerOrder()
      Determines the maximum number of times this offer can be used on a single order. A value of 0 indicates unlimited usage. Default is 0.
      Returns:
      the maximum number of times this offer can be used on a single order.
    • getMaxSavingsPerOrder

      public javax.money.MonetaryAmount getMaxSavingsPerOrder()
      Determines the maximum savings a single order can receive from this offer. For example, suppose this field has a value of $50 and this is a 10% off offer. If the order's total is $600, then it would receive a $50 discount instead of $60 (i.e., 10%). A value of 0 indicates unlimited usage. Default is 0.
      Returns:
      The maximum savings a single order can receive from this offer.
    • getMaxUsesPerUser

      public int getMaxUsesPerUser()
      Determines the maximum number of times this offer can be used by the same user. Works in conjunction with maxUsesPerUserFrequency to limit the frequency with which an individual user can use this offer. A value of 0 indicates unlimited usage. Default is 0.
      Returns:
      the maximum number of times this offer can be used by the same user.
    • getMaxUsesPerUserFrequency

      public int getMaxUsesPerUserFrequency()
      This field works in conjunction with maxUsesPerUser to limit the frequency with which an individual user can use this offer. If maxUsesPerUser = 3 and maxUsesPerUserFrequency = 5, then a user cannot use this offer more than 3 times in any 5 day period. Note that this is a sliding-window of opportunity. If a user uses this offer on days 1, 4, and 5, then they can use it on 6 but not on 7 since day 7 is within 5 days of days 4, 5, and 6. A value of 0 indicates that a user can only use this maxUsesPerUser times ever. Default is 0.
      Returns:
      the length of time in days during which a user can use this offer maxUsesPerUser times.
    • getMaxUsesPerUserStrategy

      public String getMaxUsesPerUserStrategy()
      Enum that allows implementations to vary how user max uses will be interpreted. By default the strategy will be UserMaxUsesStrategyType.CUSTOMER.
      Returns:
      the strategy for determining user max uses.
    • getOrderCriteria

      public String getOrderCriteria()

      String expression used in conjunction with itemQualifierCriteria to determine if an order qualifies for this offer. Whereas itemQualifierCriteria runs against an order's items, these criteria are run against general order attributes like locale, currencyCode, subtotal, etc. For example, this allows for restricting this offer only to orders with subtotals greater than $100.

      Can be a string representation of a SpelExpression, e.g., name == 'some-name' || id == '1', or that of some other expression language.

      Returns:
      String expression used in conjunction with itemQualifierCriteria to determine if an order qualifies for this offer.
    • getCartSubtotal

      public javax.money.MonetaryAmount getCartSubtotal()
      The minimum cart subtotal to apply this offer. If this value is specified, this offer will only apply if the cart subtotal is equal to or greater than this value.
      Returns:
      the minimum cart subtotal to apply this offer
    • getFgItemSubtotal

      public javax.money.MonetaryAmount getFgItemSubtotal()
      The minimum total for all items in a fulfillment group to apply this offer. This is only relevant to fulfillment group offers and has no effect on other offer types. This property supports promotions like free shipping if you spend $200 in ship to home products.
      Returns:
      the minimum fulfillment group item subtotal to apply this offer
    • getFulfillmentGroupCriteria

      public String getFulfillmentGroupCriteria()

      String expression used to determine if a fulfillment group qualifies for this offer. For example, this allows for restricting this offer only to fulfillment groups with shipping price greater than $100.

      Can be a string representation of a SpelExpression, e.g., name == 'some-name' || id == '1', or that of some other expression language.

      Returns:
      String expression used to determine if a fulfillment group qualifies for this offer.
    • getTimeCriteria

      public String getTimeCriteria()

      String expression used to determine whether this offer can be qualified for only at certain times or on certain days or months. For example, this allows an offer to only be applicable on Fridays or the last day of any month.

      Can be a string representation of a SpelExpression, e.g., name == 'some-name' || id == '1', or that of some other expression language.

    • getUserTargets

      public Set<UserTarget> getUserTargets()
      Set of users directly targeted by this offer.
      Returns:
      Set of users directly targeted by this offer.
      See Also:
    • isUseQtyOnlyTierCalculation

      public boolean isUseQtyOnlyTierCalculation()

      Determines whether to match an offer tier's min quantity against the number of items in an order or to match it against the number of target item sets that match an offer's target item criteria.

      Consider the following offer:

      • Has 2 tiers:
        • 1st tier min quantity: 1
        • 2nd tier: 5
      • An order must meet the following target item criteria
        • Has 3 items in the "Hot Sauces" category
        • and 1 item in the "Merchandise" category

      When useQtyOnlyTierCalculation = false, the 2nd tier would apply if the order had 3 hot sauces, 1 t-shirt, and at least 1 of an item in any category. When it's true, then the order must have 5 sets of 3 hot sauces and 1 t-shirt, that is, 15 hot sauces and 5 t-shirts to match this offer.

      Returns:
      whether to match an offer tier's min quantity against the number of items in an order or to match it against the number of target item set that match an offer's target item criteria.
    • getSubscriptionDiscount

      public SubscriptionDiscount getSubscriptionDiscount()
      Information around discounting subscription items that have recurring billing.
      Returns:
      Information around discounting subscription items that have recurring billing.
    • isQualifyFulfillmentAcrossAllItems

      public boolean isQualifyFulfillmentAcrossAllItems()
      Whether items across the entire order should be considered as potential qualifiers for fulfillment groups instead of just the items in the same fulfillment group. Default behavior is to use only the items within the fulfillment group as qualifiers.
      Returns:
      Whether items across the entire order should be considered in item-level qualifiers for a given fulfillment group.
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getTargetGroupingStrategy

      public String getTargetGroupingStrategy()
      The target grouping strategy. This affects how order items are grouped when applying discounts. Optional. If not set, defaults to TargetGroupingStrategy.COSTLIEST.

      See Also:
    • getAttributes

      public Map<String,Attribute> getAttributes()
      Dynamic attributes that are a part of the offer. This is an admin-centered concept
      Returns:
      dynamic attributes that are a part of the offer
    • isFreeGift

      public boolean isFreeGift()
      Determines whether this is a free gift offer.
      Returns:
      whether this is a free gift offer
    • getFreeProduct

      public String getFreeProduct()
      Defines the id of the free product for this offer.
      Returns:
      the sku of the free product for this offer
    • isVoucher

      public boolean isVoucher()
      Determines whether this is a voucher offer.
      Returns:
      whether this is a voucher offer
    • getVoucherCampaign

      public String getVoucherCampaign()
      Defines the id of the campaign for this offer.
      Returns:
      the id of the campaign for this offer
    • getEstimatedValue

      public BigDecimal getEstimatedValue()
      Provide an estimated value for this offer. This is used when comparing one offer combination with another.

      This property was added for voucher offers where a voucher can represent a later value. If two vouchers are not combinable, the one with the higher estimated value will be used. Likewise, if a there is a voucher offer and an order offer that are not combinable, the one with the higher value will be used.

      This property is used for free gift offers as well.

      Returns:
      the id of the campaign for this offer
    • getFulfillmentServiceLevel

      public String getFulfillmentServiceLevel()
      For Fulfillment offers, restrict the discount to a specific service level. For most applications, a fulfillment group has a single service level but some implementations allow the items in the group to have a variety of service levels (e.g. some NEXTDAY, some STANDARD). When this value is set, it will only impact the amount for the selected service levels. If this value is not set, the discount will apply to the group fulfillment price as a whole.
      Returns:
      the fulfillment service level this offer is targeting
    • getRoundDiscountsByItemUnit

      public Boolean getRoundDiscountsByItemUnit()
      For testing. Future enhancement to allow population via a JpaOrder property.
    • setId

      public void setId(String id)
      The context ID of the offer.
      Parameters:
      id - the context ID of the offer.
    • setExternalId

      public void setExternalId(String externalId)
      This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
      Parameters:
      externalId - an external ID, often a DB or business ID, from a system outside of Broadleaf
    • setName

      public void setName(String name)
      Display name for this offer.
      Parameters:
      name - the name of this offer
    • setDescription

      public void setDescription(String description)
      Description of this offer.
      Parameters:
      description - Description of this offer.
    • setCartLabel

      public void setCartLabel(String cartLabel)
      A label for this offer typically used by the storefront.
      Parameters:
      cartLabel - A label for this offer typically used by the storefront.
    • setTieredDiscount

      @Deprecated public void setTieredDiscount(boolean tieredDiscount)
      Deprecated.
      See offerDiscountStrategy. Offers with this value set to true are now considered to have a discount strategy of OfferDiscountStrategy.TIERED_ITEM_QTY. To check if an offer is tiered, use isTieredOffer()

      Determines whether this offer uses tiered discounts such that the discount changes per item quantity. For example, an offer could have 3 tiers:

      • Tier 1: if 0-3 items, then the discount is 10%
      • Tier 2: if 4-10 items, then the discount is 15%
      • Tier 3: if 11+ items, then the discount is 20%
      Default is false.

      If true, then Discount.getMethodType() and Discount.getAmount() are overridden by the same fields in the tiers (see DiscountTier).

      Parameters:
      tieredDiscount - whether this offer uses tiered discounts
      See Also:
    • setOfferDiscountStrategy

      public void setOfferDiscountStrategy(String offerDiscountStrategy)
      Represents the discount strategy for this offer. Refer to OfferDiscountStrategy for supported offer strategies.
      Parameters:
      offerDiscountStrategy - The offer discount strategy
    • setDiscountTiers

      public void setDiscountTiers(List<DiscountTier> discountTiers)
      List of discount tiers determining the discount applied with this offer.
      Parameters:
      discountTiers - List of discount tiers for this offer
      See Also:
    • setDiscount

      public void setDiscount(Discount discount)

      Basic discount information for this offer.

      If tieredDiscount is true, then Discount.getMethodType() and Discount.getAmount() are overridden by the same fields in the tiers (see DiscountTier).

      Parameters:
      discount - The Discount for this offer
    • setCurrency

      public void setCurrency(@Nullable javax.money.CurrencyUnit currency)
      The currency that an EnhancedOrder.getCurrency() must be for this offer to apply.

      This is typically used for offers where currency matters more. For example, an offer with Discount.getAmount() of 5 has different values in USD and EUR.

      Specified by:
      setCurrency in interface com.broadleafcommerce.money.CurrencyConsumer
    • setPriority

      public void setPriority(Long priority)
      When multiple offers match a context, the offer with the higher priority is applied first, where smaller integer values represent higher priorities. When used for comparisons, null should treated as lowest priority per getPriorityForComparisons().
      Parameters:
      priority - the relative precedence of this offer vs others that can also be applied in the same context
    • setActiveStartDate

      public void setActiveStartDate(Instant activeStartDate)
      Defines the beginning time for which this offer is active.
      Parameters:
      activeStartDate - The date after which this offer is active
    • setActiveEndDate

      public void setActiveEndDate(Instant activeEndDate)
      Defines the ending time for which this offer is active. Must be later than activeStartDate or null which indicates that this offer applies indefinitely.
      Parameters:
      activeEndDate - The date before which this offer is active
    • setCombinabilityOverrides

      public void setCombinabilityOverrides(Set<CombinabilityOverride> combinabilityOverrides)
      The CombinabilityOverrides that override how this offer combines with other offers.
      Parameters:
      combinabilityOverrides - the combinability overrides for this offer
      See Also:
    • setOfferCodes

      public void setOfferCodes(Set<OfferCode> offerCodes)
      The shared codes that can be used to retrieve this offer. These codes would be used in situations where this offer is not automatically considered (meaning automaticallyConsidered is false}
      Parameters:
      offerCodes - the codes that can be used to retrieve this offer
    • setCampaignTrackingIds

      public void setCampaignTrackingIds(Set<String> campaignTrackingIds)
      The tracking identifiers of the campaigns of which this offer is a part. See com.broadleafcommerce.promotion.campaign.domain.Campaign#id
    • setSegment

      public void setSegment(String segment)
      The segments to which this offer can apply. Segments are useful for systems that create offers for portions of the cart. For example, a vendor might have 10% off all items in the "vendor A" segment. Another example, is a site that uses a shared cart for 3 different store concepts (aka banners). A value of null, empty or "ANY" is the most common usage and means that this offer can apply to any qualifying part of the order. This field qualifies items using the EnhancedLineItem.getSegment() property.
    • setCombinabilityType

      public void setCombinabilityType(String combinabilityType)
      Determines whether this offer can be combined with other offers. Default is CombinabilityType.ANY, meaning this offer is combinable with any other offer.
      Parameters:
      combinabilityType - the type of combinability this offer has with other offers
      See Also:
    • setStackable

      public void setStackable(boolean stackable)
      Determines whether this offer can be stacked on top of other offers of the same type. This is different than CombinabilityType.ANY which indicates tha two offers can coexist in the same order but doesn't allow them to apply to the same target. For example, consider two offers where the first is "10% off jeans" and the second is "5% off clothing". If these are not stackable, then any jeans in the order will get 10% off while other clothing will get 5% off. If they are stackable, the jeans will get both offers and be 15% off.
      Parameters:
      combinabilityType - the type of combinability this offer has with other offers
      See Also:
    • setAutomaticallyConsidered

      public void setAutomaticallyConsidered(boolean automaticallyConsidered)

      Determines whether this offer should be considered to be applied without needing any shared codes (or some other, similar constraint). Default is false.

      Setting to true does not guarantee that the offer will be applied. All criteria and rules associated with this offer must still be met (e.g., targetItemCriteria, itemQualifierCriteria, orderCriteria, and timeCriteria).
      Parameters:
      automaticallyConsidered - whether this offer should be considered to be applied without needing any shared codes (or some other, similar constraint)
    • setPreferCartBundling

      public void setPreferCartBundling(boolean preferCartBundling)
      This property provides a hint to the front-end application to perform grouping for items that share the same discount. The intended use is for offers with multiple targets such as a "bundle offer" - that is setup as Buy 2 for $10" As the offer engine supports the concept of an item being part of more than one bundle, applications will need to make decisions on how to interpret this flag.
      Parameters:
      preferCartBundling - Whether applications should attempt to group items that share this discount
    • setDistributeOfferAmountToTargets

      public void setDistributeOfferAmountToTargets(boolean distributeOfferAmountToTargets)
      This property impacts the way that items share the same discount. The intended use is for offers with multiple targets such as a "bundle offer" - that is setup as Buy 2 for $10"
      Parameters:
      distributeOfferAmountToTargets - Should the amount property be distributed to all targets
    • setRequiresRelatedTargetAndQualifiers

      public void setRequiresRelatedTargetAndQualifiers(boolean requiresRelatedTargetAndQualifiers)
      Determines whether a qualifier must be matched to targets that are in its lineage, that is, targets must either be descended from or an ancestor of a qualifier. This is discovered by repeatedly calling the qualifier's EnhancedOrderLineItem.getParent() to find the root ancestor; then, from the root, repeatedly calling EnhancedOrderLineItem.getChildren() to find if a potential order item is a descendant thereof, that is, in the same lineage as the qualifier.
      Parameters:
      requiresRelatedTargetAndQualifiers - whether a qualifier must be matched to targets that are in its lineage
    • setItemQualifierCriteria

      public void setItemQualifierCriteria(ItemCriteria itemQualifierCriteria)
      Info related to determining what items are required so that an order or other items qualify to receive this offer's discount. If these items should not just qualify but also receive the discount, then set Discount.getProrationType() to ProrationType.TARGET_AND_QUALIFIER.
      Parameters:
      itemQualifierCriteria - Info related determining how an entity can qualify to receive this offer.
      See Also:
    • setMinTotalOfQualifierPrices

      public void setMinTotalOfQualifierPrices(javax.money.MonetaryAmount minTotalOfQualifierPrices)
      Determines the price subtotal threshold that all qualifying items must reach in addition to itemQualifierCriteria in order to qualify an order items to receive this offer's discount. That is, the system will find all qualifying items (based on itemQualifierCriteria) for the given offer and sum their prices before any discounts are applied. If that sum reaches or exceeds this minTotalOfQualifierPrices, then the targets of the offer "qualify" to receive the discount.
      Parameters:
      minTotalOfQualifierPrices - the price subtotal threshold that all qualifying items must reach in addition to itemQualifierCriteria in order to qualify an order items to receive this offer's discount.
    • setQualifiersCanBeQualifiers

      public void setQualifiersCanBeQualifiers(boolean qualifiersCanBeQualifiers)
      Determines whether items that qualify an order to receive this offer's discount can also be used as qualifiers for other offers of the same type (e.g., Order, Order Item, Fulfillment). For example, if an offer requires that an order contains a "red t-shirt" item in order to qualify for a 10% discount and another offer also requires that a "red t-shirt" be present to qualify for a 10% shipping discount, then this field determines whether that red t-shirt can be used by both offers to qualify the order for both 10% off the subtotal and 10% off shipping or if only the better offer can be applied. Default is false: A single qualifier cannot cause more than 1 offer to be applied.
      Parameters:
      qualifiersCanBeQualifiers - whether items that qualify an order to receive this offer's discount can also be used as qualifiers by other offers.
    • setQualifiersCanBeTargets

      public void setQualifiersCanBeTargets(boolean qualifiersCanBeTargets)
      Determines whether items that qualify an order to receive this offer's discount can also receive discounts from other offers of the same type (e.g., Order, Order Item, Fulfillment). For example, if this offer requires that an order contains a "red t-shirt" be present to qualify for a 10% discount on another item (think BOGO) and another offer targets that same "red t-shirt" for a 10% discount (rather than as a qualifier), then this field determines whether that red t-shirt can both qualify the another item for a 10% discount and itself receive a 10% discount or just 1 can be discounted. Default is false: A qualifier cannot also receive an individual discount.
      Parameters:
      qualifiersCanBeTargets - Determines whether items that qualify an order to receive this offer's discount can also receive discounts from other offers.
    • setApplyDiscountToAllTargets

      public void setApplyDiscountToAllTargets(Boolean applyDiscountToAllTargets)
      Returns TRUE if this ITEM offer should be applied to all discountable target items in the order. Setting this value to TRUE will not require getTargetItemCriteria() to be entered for an ITEM promotion. If the value is null, delegates to hasTargetItemCriteriaRules().
    • setExcludeDiscountedItemsFromTotals

      public void setExcludeDiscountedItemsFromTotals(Boolean excludeDiscountedItemsFromTotals)
      This property controls how order and fulfillment group offers consider subtotal qualifications. Some offers may only want to consider items that have not already received a discount as part of the subtotal calculation.
    • setApplyRemainderToFulfillment

      public void setApplyRemainderToFulfillment(Boolean applyRemainderToFulfillment)
      This property applies to amount off Order offers. When set, it allows the amount off to apply to both the Order total and the Fulfillment total. For example, if the offer amount was $50 and the order subtotal was $45 and the fulfillment price was $10, this property will allow the order offer to adjust the order by $45 and then use the remainder ($5) off of the fulfillment price leaving a cart total of $5.
    • setTargetItemCriteria

      public void setTargetItemCriteria(ItemCriteria targetItemCriteria)
      Info related to determining what order items can receive this offer's discount.
      Parameters:
      targetItemCriteria - Info related to determining what items can receive this offer's discount.
      See Also:
    • setMinTotalOfTargetPrices

      public void setMinTotalOfTargetPrices(javax.money.MonetaryAmount minTotalOfTargetPrices)
      Determines the price subtotal threshold that all targeted items must reach in addition to targetItemCriteria in order to receive this offer's discount. That is, the system will find all targeted items in an order and sum their prices before any discounts are applied. If the sum reaches or exceeds this minTotalOfTargetPrices, then the targets can receive the discount.
      Parameters:
      minTotalOfTargetPrices - the price subtotal threshold that all targeted items must reach in addition to targetItemCriteria in order to receive this offer's discount.
    • setMaxUses

      public void setMaxUses(int maxUses)
      Determines the maximum number of times this offer can be used. A value of 0 indicates unlimited usage. Default is 0.
      Parameters:
      maxUses - the maximum number of times this offer can be used.
    • setMaxTotalDiscount

      public void setMaxTotalDiscount(javax.money.MonetaryAmount maxTotalDiscount)
      Determines the maximum savings this offer is valid for. For example, this offer can discount a total of $5000 before it is considered unavailable for further usage. A value of 0 indicates unlimited usage. Default is 0.
      Parameters:
      maxTotalDiscount - the maximum savings this offer is valid for.
    • setGeneralMaxUsageStatus

      public void setGeneralMaxUsageStatus(String generalMaxUsageStatus)
      If an offer has been deemed to have exceeded is max usage threshold, this field will be set with a reason as denoted by MaxUsageStatusType. This reason applies to general offer usage as specified by either getMaxUses(), or getMaxTotalDiscount(). Exceeding max thresholds for specific order or users scenarios is not tracked here. Status will be MaxUsageStatusType.VIABLE when the offer has not exceeded thresholds yet, or is not bound by max usage thresholds.
    • setMaxUsesPerOrder

      public void setMaxUsesPerOrder(int maxUsesPerOrder)
      Determines the maximum number of times this offer can be used on a single order. A value of 0 indicates unlimited usage. Default is 0.
      Parameters:
      maxUsesPerOrder - the maximum number of times this offer can be used on a single order.
    • setMaxSavingsPerOrder

      public void setMaxSavingsPerOrder(javax.money.MonetaryAmount maxSavingsPerOrder)
      Determines the maximum savings a single order can receive from this offer. For example, suppose this field has a value of $50 and this is a 10% off offer. If the order's total is $600, then it would receive a $50 discount instead of $60 (i.e., 10%). A value of 0 indicates unlimited usage. Default is 0.
      Parameters:
      maxSavingsPerOrder - The maximum savings a single order can receive from this offer.
    • setMaxUsesPerUser

      public void setMaxUsesPerUser(int maxUsesPerUser)
      Determines the maximum number of times this offer can be used by the same user. Works in conjunction with maxUsesPerUserFrequency to limit the frequency with which an individual user can use this offer. A value of 0 indicates unlimited usage. Default is 0.
      Parameters:
      maxUsesPerUser - the maximum number of times this offer can be used by the same user.
    • setMaxUsesPerUserFrequency

      public void setMaxUsesPerUserFrequency(int maxUsesPerUserFrequency)
      This field works in conjunction with maxUsesPerUser to limit the frequency with which an individual user can use this offer. If maxUsesPerUser = 3 and maxUsesPerUserFrequency = 5, then a user cannot use this offer more than 3 times in any 5 day period. Note that this is a sliding-window of opportunity. If a user uses this offer on days 1, 4, and 5, then they can use it on 6 but not on 7 since day 7 is within 5 days of days 4, 5, and 6. A value of 0 indicates that a user can only use this maxUsesPerUser times ever. Default is 0.
      Parameters:
      maxUsesPerUserFrequency - the length of time in days during which a user can use this offer maxUsesPerUser times.
    • setMaxUsesPerUserStrategy

      public void setMaxUsesPerUserStrategy(String maxUsesPerUserStrategy)
      Enum that allows implementations to vary how user max uses will be interpreted. By default the strategy will be UserMaxUsesStrategyType.CUSTOMER.
      Parameters:
      maxUsesPerUserStrategy - the strategy for determining user max uses.
    • setOrderCriteria

      public void setOrderCriteria(String orderCriteria)

      String expression used in conjunction with itemQualifierCriteria to determine if an order qualifies for this offer. Whereas itemQualifierCriteria runs against an order's items, these criteria are run against general order attributes like locale, currencyCode, subtotal, etc. For example, this allows for restricting this offer only to orders with subtotals greater than $100.

      Can be a string representation of a SpelExpression, e.g., name == 'some-name' || id == '1', or that of some other expression language.

      Parameters:
      orderCriteria - String expression used in conjunction with itemQualifierCriteria to determine if an order qualifies for this offer.
    • setCartSubtotal

      public void setCartSubtotal(javax.money.MonetaryAmount cartSubtotal)
      The minimum cart subtotal to apply this offer. If this value is specified, this offer will only apply if the cart subtotal is equal to or greater than this value.
      Parameters:
      cartSubtotal - the minimum cart subtotal to apply this offer
    • setFgItemSubtotal

      public void setFgItemSubtotal(javax.money.MonetaryAmount fgItemSubtotal)
      The minimum total for all items in a fulfillment group to apply this offer. This is only relevant to fulfillment group offers and has no effect on other offer types. This property supports promotions like free shipping if you spend $200 in ship to home products.
      Parameters:
      fgItemSubtotal - the minimum total of all items in a fulfillment group required to apply this offer
    • setFulfillmentGroupCriteria

      public void setFulfillmentGroupCriteria(String fulfillmentGroupCriteria)

      String expression used to determine if a fulfillment group qualifies for this offer. For example, this allows for restricting this offer only to fulfillment groups with shipping price greater than $100.

      Can be a string representation of a SpelExpression, e.g., name == 'some-name' || id == '1', or that of some other expression language.

      Parameters:
      fulfillmentGroupCriteria - String expression used to determine if a fulfillment group qualifies for this offer.
    • setTimeCriteria

      public void setTimeCriteria(String timeCriteria)

      String expression used to determine whether this offer can be qualified for only at certain times or on certain days or months. For example, this allows an offer to only be applicable on Fridays or the last day of any month.

      Can be a string representation of a SpelExpression, e.g., name == 'some-name' || id == '1', or that of some other expression language.

    • setUserTargets

      public void setUserTargets(Set<UserTarget> userTargets)
      Set of users directly targeted by this offer.
      Parameters:
      userTargets - Set of users directly targeted by this offer.
      See Also:
    • setUseQtyOnlyTierCalculation

      public void setUseQtyOnlyTierCalculation(boolean useQtyOnlyTierCalculation)

      Determines whether to match an offer tier's min quantity against the number of items in an order or to match it against the number of target item sets that match an offer's target item criteria.

      Consider the following offer:

      • Has 2 tiers:
        • 1st tier min quantity: 1
        • 2nd tier: 5
      • An order must meet the following target item criteria
        • Has 3 items in the "Hot Sauces" category
        • and 1 item in the "Merchandise" category

      When useQtyOnlyTierCalculation = false, the 2nd tier would apply if the order had 3 hot sauces, 1 t-shirt, and at least 1 of an item in any category. When it's true, then the order must have 5 sets of 3 hot sauces and 1 t-shirt, that is, 15 hot sauces and 5 t-shirts to match this offer.

      Parameters:
      useQtyOnlyTierCalculation - whether to match an offer tier's min quantity against the number of items in an order or to match it against the number of target item set that match an offer's target item criteria.
    • setSubscriptionDiscount

      public void setSubscriptionDiscount(SubscriptionDiscount subscriptionDiscount)
      Information around discounting subscription items that have recurring billing.
      Parameters:
      subscriptionDiscount - Information around discounting subscription items that have recurring billing.
    • setQualifyFulfillmentAcrossAllItems

      public void setQualifyFulfillmentAcrossAllItems(boolean qualifyFulfillmentAcrossAllItems)
      Whether items across the entire order should be considered as potential qualifiers for fulfillment groups instead of just the items in the same fulfillment group. Default behavior is to use only the items within the fulfillment group as qualifiers.
      Parameters:
      qualifyFulfillmentAcrossAllItems - Whether items across the entire order should be considered in item-level qualifiers for a given fulfillment group.
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setTargetGroupingStrategy

      public void setTargetGroupingStrategy(String targetGroupingStrategy)
      The target grouping strategy. This affects how order items are grouped when applying discounts. Optional. If not set, defaults to TargetGroupingStrategy.COSTLIEST.

      See Also:
    • setAttributes

      public void setAttributes(Map<String,Attribute> attributes)
      Dynamic attributes that are a part of the offer. This is an admin-centered concept
      Parameters:
      attributes - dynamic attributes that are a part of the offer
    • setFreeGift

      public void setFreeGift(boolean freeGift)
      Determines whether this is a free gift offer.
      Parameters:
      freeGift - whether this is a free gift offer
    • setFreeProduct

      public void setFreeProduct(String freeProduct)
      Defines the id of the free product for this offer.
      Parameters:
      freeProduct - the sku of the free product for this offer
    • setVoucher

      public void setVoucher(boolean voucher)
      Determines whether this is a voucher offer.
      Parameters:
      voucher - whether this is a voucher offer
    • setVoucherCampaign

      public void setVoucherCampaign(String voucherCampaign)
      Defines the id of the campaign for this offer.
      Parameters:
      campaign - the id of the campaign for this offer
    • setEstimatedValue

      public void setEstimatedValue(BigDecimal estimatedValue)
      Provide an estimated value for this offer. This is used when comparing one offer combination with another.

      This property was added for voucher offers where a voucher can represent a later value. If two vouchers are not combinable, the one with the higher estimated value will be used. Likewise, if a there is a voucher offer and an order offer that are not combinable, the one with the higher value will be used.

      This property is used for free gift offers as well.

      Parameters:
      estimatedValue - a value in the currency of the order
    • setFulfillmentServiceLevel

      public void setFulfillmentServiceLevel(String fulfillmentServiceLevel)
      For Fulfillment offers, restrict the discount to a specific service level. For most applications, a fulfillment group has a single service level but some implementations allow the items in the group to have a variety of service levels (e.g. some NEXTDAY, some STANDARD). When this value is set, it will only impact the amount for the selected service levels. If this value is not set, the discount will apply to the group fulfillment price as a whole.
      Parameters:
      fulfillmentServiceLevel - The service level (e.g. STANDARD or NEXTDAY)
    • setRoundDiscountsByItemUnit

      public void setRoundDiscountsByItemUnit(Boolean roundDiscountsByItemUnit)
      For testing. Future enhancement to allow population via a JpaOrder property.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object