Class Offer

  • All Implemented Interfaces:
    com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable, Comparable<Offer>

    public class Offer
    extends Object
    implements Serializable, Comparable<Offer>, com.broadleafcommerce.data.tracking.core.ContextStateAware
    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:
    Serialized Form
    • Field Detail

      • 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.
    • Constructor Detail

      • Offer

        public Offer()
    • Method Detail

      • 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:
        DiscountTimingType.FUTURE_CREDIT, Discount.getTimingType()
      • isCombinableWithOtherTypes

        public boolean isCombinableWithOtherTypes()
      • isTotalitarian

        public boolean isTotalitarian()
      • 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.
      • 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.
      • isTieredOffer

        public boolean isTieredOffer()
      • getPriorityForComparisons

        public Long getPriorityForComparisons()
      • isTieredDiscount

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

        public String getId()
        The context ID of the offer.
        Returns:
        the context ID of the offer.
      • 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.
      • 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.
        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.
        Returns:
        The date before which this offer is active
      • getSharedCodes

        public Set<SharedCode> getSharedCodes()
        The SharedCodes 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
      • 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:
        CombinabilityType
      • 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:
        CombinabilityType
      • isAutomaticallyConsidered

        public boolean isAutomaticallyConsidered()

        Determines whether this offer should be considered to be applied without needing any sharedCodes or campaignTrackingIds (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 sharedCodes or campaignTrackingIds (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:
        ItemCriteria
      • 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:
        ItemCriteria
      • 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.
      • 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
      • 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:
        UserTarget
      • 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
      • 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
      • setId

        public void setId​(String id)
        The context ID of the offer.
        Parameters:
        id - the context ID of the offer.
      • 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:
        DiscountTier, discountTiers
      • 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
      • 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
      • setSharedCodes

        public void setSharedCodes​(Set<SharedCode> sharedCodes)
        The SharedCodes 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:
        sharedCodes - 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
      • 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:
        CombinabilityType
      • 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:
        CombinabilityType
      • setAutomaticallyConsidered

        public void setAutomaticallyConsidered​(boolean automaticallyConsidered)

        Determines whether this offer should be considered to be applied without needing any sharedCodes or campaignTrackingIds (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 sharedCodes or campaignTrackingIds (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:
        ItemCriteria
      • 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.
      • 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:
        ItemCriteria
      • 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.
      • 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
      • 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:
        UserTarget
      • 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
      • 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
      • canEqual

        protected boolean canEqual​(Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object