Class PromotableCandidateItemOfferImpl
java.lang.Object
org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl
- All Implemented Interfaces:
Serializable,OfferHolder,PromotableCandidateItemOffer,PromotionRounding
public class PromotableCandidateItemOfferImpl
extends AbstractPromotionRounding
implements PromotableCandidateItemOffer, OfferHolder
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap<OfferPriceData,List<PromotableOrderItem>> protected HashMap<OfferItemCriteria,List<PromotableOrderItem>> protected HashMap<OfferItemCriteria,List<PromotableOrderItem>> protected List<PromotableOrderItem>protected intprotected Offerprotected Moneyprotected Moneyprotected Moneyprotected PromotableOrderprotected booleanprotected intprotected BigDecimalFields inherited from class org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
roundingMode, roundingScale -
Constructor Summary
ConstructorsConstructorDescriptionPromotableCandidateItemOfferImpl(PromotableOrder promotableOrder, Offer offer) PromotableCandidateItemOfferImpl(PromotableOrder promotableOrder, Offer offer, boolean useQtyOnlyTierCalculation) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUse()intDetermines the maximum number of times this promotion can be used based on the ItemCriteria and promotion's maxQty setting.intcalculateMaxUsesForItemCriteria(OfferItemCriteria itemCriteria, Offer promotion) Determines the max number of times this itemCriteria might apply.intReturns the number of items that potentially could be targets for the offer.intIf the offer has a minimum required number of targets, then the first time this offer is processed, return that number.getOffer()intintgetUses()booleanbooleanReturns whether to use quantity only tier calculation.voidResets the uses for this candidate offer item.voidsetCandidateFixedTargetsMap(HashMap<OfferPriceData, List<PromotableOrderItem>> candidateFixedTargetsMap) voidsetCandidateQualifiersMap(HashMap<OfferItemCriteria, List<PromotableOrderItem>> candidateItemsMap) voidsetCandidateTargetsMap(HashMap<OfferItemCriteria, List<PromotableOrderItem>> candidateItemsMap) voidsetLegacyCandidateTargets(List<PromotableOrderItem> candidateTargets) voidsetMinimumTargetsRequired(Integer minimumTargetsRequired) voidsetOriginalPrice(Money originalPrice) voidsetPotentialSavings(Money potentialSavings) voidsetPotentialSavingsQtyOne(Money potentialSavingsQtyOne) voidsetUseQtyOnlyTierCalculation(boolean useQtyOnlyTierCalculation) Sets whether to use quantity only tier calculation.voidsetWeightedPercentSaved(BigDecimal weightedPercentSaved) Methods inherited from class org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
getRoundingMode, getRoundingScale, setRoundingMode, setRoundingScaleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.broadleafcommerce.core.offer.service.discount.domain.PromotionRounding
getRoundingMode, getRoundingScale
-
Field Details
-
offer
-
promotableOrder
-
potentialSavings
-
potentialSavingsQtyOne
-
weightedPercentSaved
-
originalPrice
-
uses
protected int uses -
useQtyOnlyTierCalculation
protected boolean useQtyOnlyTierCalculation -
candidateQualifiersMap
-
candidateTargetsMap
-
candidateFixedTargetsMap
-
legacyCandidateTargets
-
minimumTargetsRequired
protected int minimumTargetsRequired
-
-
Constructor Details
-
PromotableCandidateItemOfferImpl
-
PromotableCandidateItemOfferImpl
public PromotableCandidateItemOfferImpl(PromotableOrder promotableOrder, Offer offer, boolean useQtyOnlyTierCalculation)
-
-
Method Details
-
getCurrency
- Specified by:
getCurrencyin interfaceOfferHolder
-
calculateTargetQuantityForTieredOffer
public int calculateTargetQuantityForTieredOffer()Returns the number of items that potentially could be targets for the offer. Due to combination or bogo logic, they may not all get the tiered offer price.- Specified by:
calculateTargetQuantityForTieredOfferin interfacePromotableCandidateItemOffer- Returns:
-
getPotentialSavings
- Specified by:
getPotentialSavingsin interfacePromotableCandidateItemOffer
-
setPotentialSavings
- Specified by:
setPotentialSavingsin interfacePromotableCandidateItemOffer
-
getPotentialSavingsQtyOne
- Specified by:
getPotentialSavingsQtyOnein interfacePromotableCandidateItemOffer
-
setPotentialSavingsQtyOne
- Specified by:
setPotentialSavingsQtyOnein interfacePromotableCandidateItemOffer
-
hasQualifyingItemCriteria
public boolean hasQualifyingItemCriteria()- Specified by:
hasQualifyingItemCriteriain interfacePromotableCandidateItemOffer
-
calculateMaximumNumberOfUses
public int calculateMaximumNumberOfUses()Determines the maximum number of times this promotion can be used based on the ItemCriteria and promotion's maxQty setting.- Specified by:
calculateMaximumNumberOfUsesin interfacePromotableCandidateItemOffer
-
calculateMaxUsesForItemCriteria
Description copied from interface:PromotableCandidateItemOfferDetermines the max number of times this itemCriteria might apply. This calculation does not take into account other promotions. It is useful only to assist in prioritizing the order to process the promotions.- Specified by:
calculateMaxUsesForItemCriteriain interfacePromotableCandidateItemOffer- Returns:
-
getCandidateQualifiersMap
- Specified by:
getCandidateQualifiersMapin interfacePromotableCandidateItemOffer
-
setCandidateQualifiersMap
public void setCandidateQualifiersMap(HashMap<OfferItemCriteria, List<PromotableOrderItem>> candidateItemsMap) - Specified by:
setCandidateQualifiersMapin interfacePromotableCandidateItemOffer
-
getCandidateTargetsMap
- Specified by:
getCandidateTargetsMapin interfacePromotableCandidateItemOffer
-
setCandidateTargetsMap
public void setCandidateTargetsMap(HashMap<OfferItemCriteria, List<PromotableOrderItem>> candidateItemsMap) - Specified by:
setCandidateTargetsMapin interfacePromotableCandidateItemOffer
-
getCandidateFixedTargetsMap
- Specified by:
getCandidateFixedTargetsMapin interfacePromotableCandidateItemOffer
-
setCandidateFixedTargetsMap
public void setCandidateFixedTargetsMap(HashMap<OfferPriceData, List<PromotableOrderItem>> candidateFixedTargetsMap) - Specified by:
setCandidateFixedTargetsMapin interfacePromotableCandidateItemOffer
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfacePromotableCandidateItemOffer
-
getOffer
- Specified by:
getOfferin interfaceOfferHolder- Specified by:
getOfferin interfacePromotableCandidateItemOffer
-
getUses
public int getUses()- Specified by:
getUsesin interfacePromotableCandidateItemOffer
-
addUse
public void addUse()- Specified by:
addUsein interfacePromotableCandidateItemOffer
-
resetUses
public void resetUses()Description copied from interface:PromotableCandidateItemOfferResets the uses for this candidate offer item. This is mainly used in the case where we want to calculate savings and then actually apply the promotion to an item. Both scenarios run through the same logic that add uses in order to determine if various quantities of items can be targeted for a particular promotion.- Specified by:
resetUsesin interfacePromotableCandidateItemOffer
-
getLegacyCandidateTargets
- Specified by:
getLegacyCandidateTargetsin interfacePromotableCandidateItemOffer
-
setLegacyCandidateTargets
- Specified by:
setLegacyCandidateTargetsin interfacePromotableCandidateItemOffer
-
getWeightedPercentSaved
- Specified by:
getWeightedPercentSavedin interfacePromotableCandidateItemOffer
-
setWeightedPercentSaved
- Specified by:
setWeightedPercentSavedin interfacePromotableCandidateItemOffer
-
getOriginalPrice
- Specified by:
getOriginalPricein interfacePromotableCandidateItemOffer
-
setOriginalPrice
- Specified by:
setOriginalPricein interfacePromotableCandidateItemOffer
-
setMinimumTargetsRequired
- Specified by:
setMinimumTargetsRequiredin interfacePromotableCandidateItemOffer- See Also:
-
MiniumTargetsRequired
-
getMinimumRequiredTargetQuantity
public int getMinimumRequiredTargetQuantity()If the offer has a minimum required number of targets, then the first time this offer is processed, return that number. On subsequent runs, return 1.- Specified by:
getMinimumRequiredTargetQuantityin interfacePromotableCandidateItemOffer- Returns:
- See Also:
-
isUseQtyOnlyTierCalculation
public boolean isUseQtyOnlyTierCalculation()Description copied from interface:PromotableCandidateItemOfferReturns whether to use quantity only tier calculation. If set to true,PromotableCandidateItemOffer.calculateTargetQuantityForTieredOffer()will use only the quantity in cart for determining which tier level to apply for a group of qualifying items. This mode is disabled by default. To turn it back on, use `use.quantity.only.tier.calculation=true` in your `common-shared.properties`.Otherwise, the default behavior is to factor in the number of iterations that the qualifying items have been applied.
- Specified by:
isUseQtyOnlyTierCalculationin interfacePromotableCandidateItemOffer- Returns:
-
setUseQtyOnlyTierCalculation
public void setUseQtyOnlyTierCalculation(boolean useQtyOnlyTierCalculation) Description copied from interface:PromotableCandidateItemOfferSets whether to use quantity only tier calculation. If set to true,PromotableCandidateItemOffer.calculateTargetQuantityForTieredOffer()will use only the quantity in cart for determining which tier level to apply for a group of qualifying items. This mode is disabled by default. To turn it back on, use `use.quantity.only.tier.calculation=true` in your `common-shared.properties`.Otherwise, the default behavior is to factor in the number of iterations that the qualifying items have been applied.
- Specified by:
setUseQtyOnlyTierCalculationin interfacePromotableCandidateItemOffer
-