Class BandedFulfillmentPricingProvider
java.lang.Object
org.broadleafcommerce.core.pricing.service.fulfillment.provider.BandedFulfillmentPricingProvider
- All Implemented Interfaces:
FulfillmentPricingProvider
Used in conjunction with BandedPriceFulfillmentOption and BandedWeightFulfillmentOption.
If 2 bands are configured equal to each other (meaning, there are 2 FulfillmentPriceBands that have the
same retail price minimum or 2 FulfillmentWeightBands that have the same minimum weight),
this will choose the cheaper rate of the 2
If the retail total does not fall within a configured price band, the total cost of fulfillment is zero
Note: For BandedWeightFulfillmentOption, this assumes that all of your weights have the same units
- Author:
- Phillip Verheyden
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalculateCostForFulfillmentGroup(FulfillmentGroup fulfillmentGroup) Calculates the total cost for this FulfillmentGroup.booleancanCalculateCostForFulfillmentGroup(FulfillmentGroup fulfillmentGroup, FulfillmentOption option) Whether or not this processor can provide a cost calculate for the given FulfillmentGroup and the given FulfillmentOption.protected BigDecimalconvertWeight(BigDecimal weight, WeightUnitOfMeasureType type) Default implementation is to convert everything to pounds for consistent weight typesestimateCostForFulfillmentGroup(FulfillmentGroup fulfillmentGroup, Set<FulfillmentOption> options) Estimates the cost for the fulfilling the given fulfillment group Estimates the cost for the fulfilling the given fulfillment group with the given options.
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
-
Constructor Details
-
BandedFulfillmentPricingProvider
public BandedFulfillmentPricingProvider()
-
-
Method Details
-
canCalculateCostForFulfillmentGroup
public boolean canCalculateCostForFulfillmentGroup(FulfillmentGroup fulfillmentGroup, FulfillmentOption option) Description copied from interface:FulfillmentPricingProviderWhether or not this processor can provide a cost calculate for the given FulfillmentGroup and the given FulfillmentOption. This is not invoked directly by any workflow, but could instead be invoked via a controller that wants to display pricing to a user before the user actually picks a FulfillmentOption. The controller would inject an instance of FulfillmentPricingService and thus indirectly invoke this method for a particular option.- Specified by:
canCalculateCostForFulfillmentGroupin interfaceFulfillmentPricingProvideroption- - the candidate option a user might select based on the estimate- Returns:
- true if this processor can estimate the costs, false otherwise
-
calculateCostForFulfillmentGroup
public FulfillmentGroup calculateCostForFulfillmentGroup(FulfillmentGroup fulfillmentGroup) throws FulfillmentPriceException Description copied from interface:FulfillmentPricingProviderCalculates the total cost for this FulfillmentGroup. Specific configurations for calculating this cost can come fromFulfillmentGroup.getFulfillmentOption(). This method is invoked during the pricing workflow and will only be called ifFulfillmentPricingProvider.canCalculateCostForFulfillmentGroup(FulfillmentGroup, FulfillmentOption)returns true. This should callFulfillmentGroup.setShippingPrice(org.broadleafcommerce.common.money.Money)to set the shipping price on fulfillmentGroup- Specified by:
calculateCostForFulfillmentGroupin interfaceFulfillmentPricingProvider- Parameters:
fulfillmentGroup- - theFulfillmentGroupto calculate costs for- Returns:
- the modified
FulfillmentGroupwith correct pricing. This is typically fulfillmentGroup after it has been modified - Throws:
FulfillmentPriceException
-
estimateCostForFulfillmentGroup
public FulfillmentEstimationResponse estimateCostForFulfillmentGroup(FulfillmentGroup fulfillmentGroup, Set<FulfillmentOption> options) throws FulfillmentPriceException Description copied from interface:FulfillmentPricingProviderEstimates the cost for the fulfilling the given fulfillment group Estimates the cost for the fulfilling the given fulfillment group with the given options. The response should not include prices that the implementor of this interface cannot respond to. So, if the invoker of this method passes in several types of fulfillment options, the response should only contain prices for the fulfillment options that will would cause a call toFulfillmentPricingProvider.canCalculateCostForFulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup, org.broadleafcommerce.core.order.domain.FulfillmentOption)to return true. This method may return null or it may return a non-null response with an empty map, indicating that no price estimate was available for the options given. This method SHOULD NOT throw an exception if it encounters a FulfillmentOption that it can not price. It should simply ignore that option.- Specified by:
estimateCostForFulfillmentGroupin interfaceFulfillmentPricingProvider- Parameters:
fulfillmentGroup- - the group to estimate fulfillment costs foroptions- - the candidate options that a user might select- Returns:
- a DTO that represents pricing information that might be added to the fulfillment cost of fulfillmentGroup when
FulfillmentPricingProvider.calculateCostForFulfillmentGroup(FulfillmentGroup)is invoked during the pricing workflow - Throws:
FulfillmentPriceException
-
convertWeight
Default implementation is to convert everything to pounds for consistent weight types- Parameters:
weight-type-- Returns:
-