Class VirtualFulfillmentPricingProvider
java.lang.Object
com.broadleafcommerce.shipping.service.integrations.virtual.VirtualFulfillmentPricingProvider
- All Implemented Interfaces:
- FulfillmentPricingProvider
- 
Constructor SummaryConstructorsConstructorDescriptionVirtualFulfillmentPricingProvider(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, VirtualFulfillmentPricingProperties virtualShipProps) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponsebuildFulfillmentOptionPricedResponse(@NonNull javax.money.MonetaryAmount price, @NonNull Map<com.broadleafcommerce.shipping.domain.FulfillmentPricingItem, javax.money.MonetaryAmount> itemToPriceMap, @NonNull VirtualFulfillmentPricingOption fulfillmentOption, boolean isEstimate) Builds aFulfillmentOptionPricedResponsewith the given inputs.protected Map<com.broadleafcommerce.shipping.domain.FulfillmentPricingItem,javax.money.MonetaryAmount> buildItemToPriceMap(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, @NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) Builds a map ofFulfillmentPricingItemsto the calculated prices.com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponsecalculateCostForFulfillmentGroup(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculate shipping for a request that includes a specified fulfillment option.protected com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponsecalculateCostForFulfillmentGroupInternal(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, boolean isEstimate) Deprecated, for removal: This API element is subject to removal in a future version.protected com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponsecalculateCostForFulfillmentGroupInternal(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, boolean isEstimate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculates the shipping costs of the fulfillment items based on the fulfillment option on the request.protected javax.money.MonetaryAmountcalculateFixedPriceForItem(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) Calculates the fixed price for the fulfillment item, i.e.protected javax.money.MonetaryAmountcalculateFulfillmentGroupPriceBeforeAdjustments(@NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) Calculates the fixed fulfillment price per fulfillment group.protected javax.money.MonetaryAmountcalculatePercentageBasedPriceForItem(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) protected javax.money.MonetaryAmountcalculatePercentageBasedPriceForItems(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) protected javax.money.MonetaryAmountcalculatePriceForItem(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) Deprecated.protected javax.money.MonetaryAmountcalculatePriceForItems(@NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull VirtualFulfillmentPricingOption option, @NonNull javax.money.CurrencyUnit currency) Calculates the price for a fulfillment items.booleancanCalculateCostForOption(String fulfillmentOptionName, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Whether this provider has knowledge of the provided option and thus can provide cost information for it.booleancanProvidePricedFulfillmentOptions(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest fulfillmentPricingRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Whether this provider can provide fulfillment options based on the "fulfillmentPricingRequest"com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponseestimateCostForFulfillmentGroup(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Estimate shipping for a request that includes a specified fulfillment option.protected VirtualFulfillmentPricingOptiongetDefaultVirtualFulfillmentPricingOption(@NonNull javax.money.CurrencyUnit currency) Builds aVirtualFulfillmentPricingOptionwith fields initialized to typical values.protected List<VirtualFulfillmentPricingOption>getFulfillmentOptions(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a list ofVirtualFulfillmentPricingOptionsbased on the givenContextInfo.protected javax.money.MonetaryAmountgetMonetaryAmount(javax.money.CurrencyUnit expectedCurrency, Set<com.broadleafcommerce.shipping.domain.FulfillmentPriceAmount> fulfillmentPriceAmounts) Find the corresponding price for the expected currency, otherwise return zero.protected com.fasterxml.jackson.databind.ObjectMapperprotected com.broadleafcommerce.common.extension.TypeFactoryprotected VirtualFulfillmentPricingConfigDeprecated.since 1.1.0, in favor ofVirtualFulfillmentPricingProperties.getFulfillmentOptions(ContextInfo)protected VirtualFulfillmentPricingPropertiesvoidinit()Reads in the configuration file defined byVirtualFulfillmentPricingProperties.getConfigPath()and initializesvirtualFulfillmentPricingConfigto the result.List<com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse>providePricedFulfillmentOptions(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve all possible priced fulfillment options for the provided request.protected javax.money.CurrencyUnitresolveCurrency(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.shipping.service.integrations.FulfillmentPricingProvidercalculateCostForFulfillmentGroup, canCalculateCostForOption, canProvidePricedFulfillmentOptions, estimateCostForFulfillmentGroup, getFulfillmentOptionPricingResponses, providePricedFulfillmentOptions
- 
Constructor Details- 
VirtualFulfillmentPricingProviderpublic VirtualFulfillmentPricingProvider(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, VirtualFulfillmentPricingProperties virtualShipProps) 
 
- 
- 
Method Details- 
init@PostConstruct public void init()Reads in the configuration file defined byVirtualFulfillmentPricingProperties.getConfigPath()and initializesvirtualFulfillmentPricingConfigto the result.- Throws:
- UncheckedIOException- Thrown when there is an error while reading the configuration file or converting its contents into a- VirtualFulfillmentPricingConfig.
 
- 
providePricedFulfillmentOptionspublic List<com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse> providePricedFulfillmentOptions(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:FulfillmentPricingProviderRetrieve all possible priced fulfillment options for the provided request. Intended to be used to display options to the customer for selection.- Specified by:
- providePricedFulfillmentOptionsin interface- FulfillmentPricingProvider
- Parameters:
- request- The request for which to calculate shipping and return options.
- contextInfo- context information around sandbox and multitenant state
- Returns:
- All possible priced fulfillment options for the provided request.
 
- 
canProvidePricedFulfillmentOptionspublic boolean canProvidePricedFulfillmentOptions(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest fulfillmentPricingRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:FulfillmentPricingProviderWhether this provider can provide fulfillment options based on the "fulfillmentPricingRequest"- Specified by:
- canProvidePricedFulfillmentOptionsin interface- FulfillmentPricingProvider
- Parameters:
- fulfillmentPricingRequest- The request used to identify relevant fulfillment options
- contextInfo- context information around sandbox and multitenant state
- Returns:
- Whether this provider can provide fulfillment options based on the "fulfillmentPricingRequest"
 
- 
calculateCostForFulfillmentGrouppublic com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse calculateCostForFulfillmentGroup(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:FulfillmentPricingProviderCalculate shipping for a request that includes a specified fulfillment option.- Specified by:
- calculateCostForFulfillmentGroupin interface- FulfillmentPricingProvider
- Parameters:
- request- The request for which to calculate shipping.
- contextInfo- context information around sandbox and multitenant state
- Returns:
- Response object with calculated shipping cost for the provided request.
 
- 
canCalculateCostForOptionpublic boolean canCalculateCostForOption(String fulfillmentOptionName, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:FulfillmentPricingProviderWhether this provider has knowledge of the provided option and thus can provide cost information for it.- Specified by:
- canCalculateCostForOptionin interface- FulfillmentPricingProvider
- Parameters:
- fulfillmentOptionName- The option to consider whether this provider can calculate cost information.
- contextInfo- context information around sandbox and multitenant state
- Returns:
- Whether this provider has knowledge of the provided option and thus can provide cost information for it.
 
- 
estimateCostForFulfillmentGrouppublic com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse estimateCostForFulfillmentGroup(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:FulfillmentPricingProviderEstimate shipping for a request that includes a specified fulfillment option.- Specified by:
- estimateCostForFulfillmentGroupin interface- FulfillmentPricingProvider
- Parameters:
- request- The request for which to estimate shipping.
- contextInfo- context information around sandbox and multitenant state
- Returns:
- Response object with estimated shipping cost for the provided request.
 
- 
getFulfillmentOptionsprotected List<VirtualFulfillmentPricingOption> getFulfillmentOptions(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a list ofVirtualFulfillmentPricingOptionsbased on the givenContextInfo.If VirtualFulfillmentPricingOptionscannot be found,virtualFulfillmentPricingConfigwould be used as a fallback.- Parameters:
- contextInfo- context information around sandbox and multitenant state
- Returns:
- a list of VirtualFulfillmentPricingOptionsbased on the givenContextInfo
 
- 
calculateCostForFulfillmentGroupInternal@Deprecated(since="1.1.0", forRemoval=true) protected com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse calculateCostForFulfillmentGroupInternal(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, boolean isEstimate) Deprecated, for removal: This API element is subject to removal in a future version.since 1.1.0, in favor ofcalculateCostForFulfillmentGroupInternal(FulfillmentPricingRequest, boolean, ContextInfo)
- 
calculateCostForFulfillmentGroupInternalprotected com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse calculateCostForFulfillmentGroupInternal(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, boolean isEstimate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculates the shipping costs of the fulfillment items based on the fulfillment option on the request. Handles the shared logic ofcalculateCostForFulfillmentGroup(FulfillmentPricingRequest, ContextInfo)andestimateCostForFulfillmentGroup(FulfillmentPricingRequest, ContextInfo).- Parameters:
- request- The request for which to calculate shipping
- isEstimate- Whether or not the shipping should be estimated
- contextInfo- Context information around sandbox and multitenant state
- Returns:
- fulfillment price information for request based on the fulfillment option.
 
- 
buildItemToPriceMapprotected Map<com.broadleafcommerce.shipping.domain.FulfillmentPricingItem,javax.money.MonetaryAmount> buildItemToPriceMap(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request, @NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) Builds a map ofFulfillmentPricingItemsto the calculated prices.- Parameters:
- request- The request for which to calculate shipping
- option- The fulfillment option to use to calculate pricing for the- request
- Returns:
- a map of FulfillmentPricingItemsto the calculated prices.
 
- 
calculatePriceForItem@Deprecated protected javax.money.MonetaryAmount calculatePriceForItem(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) Deprecated.Calculates the price for a fulfillment item. By default this means the price for a single unit rather than all like units, i.e.,FulfillmentPricingItem.getUnitPrice()is used notFulfillmentPricingItem.getSubtotal().- Parameters:
- item- The- FulfillmentPriceInfoitem to be priced
- option- The applicable- VirtualFulfillmentPricingOptionfor the- item
- Returns:
- the price for a fulfillment item.
 
- 
calculatePriceForItemsprotected javax.money.MonetaryAmount calculatePriceForItems(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) Calculates the price for a fulfillment items. By default this means the price for all units, i.e.,FulfillmentPricingItem.getMerchandiseTotalAmount().- Parameters:
- item- The- FulfillmentPriceInfoitem to be priced
- option- The applicable- VirtualFulfillmentPricingOptionfor the- item
- Returns:
- the price for a fulfillment items.
 
- 
calculateFixedPriceForItemprotected javax.money.MonetaryAmount calculateFixedPriceForItem(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) Calculates the fixed price for the fulfillment item, i.e. the price per item plus any flat rates for this item.- Parameters:
- item- The- FulfillmentPriceInfoitem to be priced
- option- The applicable- VirtualFulfillmentPricingOptionfor the- item
- Returns:
- the fixed price for a fulfillment item.
 
- 
calculatePercentageBasedPriceForItem@Deprecated protected javax.money.MonetaryAmount calculatePercentageBasedPriceForItem(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) Deprecated.Calculates the fulfillment price based on the percentage rate per item.- Parameters:
- item- The- FulfillmentPriceInfoitem to be priced
- option- The applicable- VirtualFulfillmentPricingOptionfor the- item
- Returns:
- the percentage rate price for a fulfillment item.
 
- 
calculatePercentageBasedPriceForItemsprotected javax.money.MonetaryAmount calculatePercentageBasedPriceForItems(@NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem item, @NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) 
- 
calculateFulfillmentGroupPriceBeforeAdjustmentsprotected javax.money.MonetaryAmount calculateFulfillmentGroupPriceBeforeAdjustments(@NonNull @NonNull VirtualFulfillmentPricingOption option, @NonNull @NonNull javax.money.CurrencyUnit currency) Calculates the fixed fulfillment price per fulfillment group.- Parameters:
- option- The applicable- VirtualFulfillmentPricingOptionfor the fulfillment group
- Returns:
- the fixed fulfillment price per fulfillment group
 
- 
getMonetaryAmountprotected javax.money.MonetaryAmount getMonetaryAmount(javax.money.CurrencyUnit expectedCurrency, @Nullable Set<com.broadleafcommerce.shipping.domain.FulfillmentPriceAmount> fulfillmentPriceAmounts) Find the corresponding price for the expected currency, otherwise return zero.- Parameters:
- expectedCurrency- The expected currency to find a price for
- fulfillmentPriceAmounts- The list of prices to search against
- Returns:
- the corresponding price for the expected currency, otherwise return zero
 
- 
buildFulfillmentOptionPricedResponseprotected com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse buildFulfillmentOptionPricedResponse(@NonNull @NonNull javax.money.MonetaryAmount price, @NonNull @NonNull Map<com.broadleafcommerce.shipping.domain.FulfillmentPricingItem, javax.money.MonetaryAmount> itemToPriceMap, @NonNull @NonNull VirtualFulfillmentPricingOption fulfillmentOption, boolean isEstimate) Builds aFulfillmentOptionPricedResponsewith the given inputs.- Parameters:
- price- The value to set for- FulfillmentOptionPricedResponse.getFulfillmentPriceCalculated().
- itemToPriceMap- Map of- FulfillmentPricingItemsto their fulfillment prices
- fulfillmentOption- The- FulfillmentOptionthat forms the basis of the response
- isEstimate- Whether this is for estimating the fulfillment pricing
- Returns:
- a FulfillmentOptionPricedResponsefor the given inputs.
 
- 
getDefaultVirtualFulfillmentPricingOptionprotected VirtualFulfillmentPricingOption getDefaultVirtualFulfillmentPricingOption(@NonNull @NonNull javax.money.CurrencyUnit currency) Builds aVirtualFulfillmentPricingOptionwith fields initialized to typical values.- Returns:
- a VirtualFulfillmentPricingOptionwith fields initialized to typical values.
 
- 
resolveCurrencyprotected javax.money.CurrencyUnit resolveCurrency(com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest request) 
- 
getObjectMapperprotected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
- 
getTypeFactoryprotected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
- 
getVirtualShipProps
- 
getVirtualFulfillmentPricingConfigDeprecated.since 1.1.0, in favor ofVirtualFulfillmentPricingProperties.getFulfillmentOptions(ContextInfo)
 
- 
calculateCostForFulfillmentGroupInternal(FulfillmentPricingRequest, boolean, ContextInfo)