Class PriceInfoContributionUtils
java.lang.Object
com.broadleafcommerce.catalog.service.util.commerce.PriceInfoContributionUtils
Utility methods for
PriceInfos
created for the response to a
ProductDetailsRequest
.- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
ConstructorDescriptionPriceInfoContributionUtils
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptioncreateItemChoicePriceInfo
(@NonNull ItemChoice itemChoice) Creates aPriceInfo
for anItemChoice
protected PriceInfo
createPriceInfoForCustomSpecificItem
(@NonNull SpecificItemChoiceDetail specificItemChoice) Extension point for creating aPriceInfo
for aSpecificItemChoiceDetail
ifits type
can be more thanDefaultSpecificItemChoiceType.PRODUCT
orDefaultSpecificItemChoiceType.VARIANT
when it and its parentItemChoice
have nooverridePrices
.createPriceInfoForIncludedProduct
(@NonNull IncludedProduct includedProduct) Creates aPriceInfo
for anIncludedProduct
.createPriceInfoForProduct
(@NonNull Product product) protected PriceInfo
createPriceInfoForSpecificItem
(@NonNull Map<String, javax.money.MonetaryAmount> pricingFields, boolean isOnSale) createPriceInfoForVariant
(@NonNull Variant variant) createPriceInfoForVariant
(@NonNull Variant variant, Product parentProduct) protected PriceInfo
createPriceInfoSpecificChoiceWithoutOverride
(@NonNull SpecificItemChoiceDetail specificChoice, PriceInfo itemChoicePriceInfo) Creates aPriceInfo
for aSpecificItemChoice
that does not have aSpecificItemChoice.getOverridePrice()
.createSpecificItemChoicePriceInfo
(@NonNull SpecificItemChoiceDetail specificChoice, PriceInfo itemChoicePriceInfo) Creates aPriceInfo
for aSpecificItemChoiceDetail
.createSpecificItemVariantPriceInfo
(SpecificItemVariantPricing variantPricing) protected PriceInfo
getPriceInfoForSpecificChoiceWithOverride
(@NonNull SpecificItemChoiceDetail specificChoice) protected com.broadleafcommerce.common.extension.TypeFactory
-
Constructor Details
-
PriceInfoContributionUtils
public PriceInfoContributionUtils(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
createPriceInfoForProduct
-
createPriceInfoForVariant
-
createPriceInfoForVariant
-
createPriceInfoForIncludedProduct
public PriceInfo createPriceInfoForIncludedProduct(@NonNull @NonNull IncludedProduct includedProduct) Creates aPriceInfo
for anIncludedProduct
.- Parameters:
includedProduct
-IncludedProduct
for which to create aPriceInfo
- Returns:
- a
PriceInfo
for anIncludedProduct
-
createItemChoicePriceInfo
Creates aPriceInfo
for anItemChoice
- Parameters:
itemChoice
-ItemChoice
for which to make aPriceInfo
- Returns:
- a
PriceInfo
for anItemChoice
-
createSpecificItemChoicePriceInfo
public PriceInfo createSpecificItemChoicePriceInfo(@NonNull @NonNull SpecificItemChoiceDetail specificChoice, @Nullable PriceInfo itemChoicePriceInfo) Creates aPriceInfo
for aSpecificItemChoiceDetail
. This will first look for anoverride price
on the specific item, then on the parentItemChoice
, and, if neither of the previous are present, it will use the specificProduct
orVariant
.- Parameters:
specificChoice
-SpecificItemChoice
for which to make aPriceInfo
- Returns:
- a
PriceInfo
for aSpecificItemChoiceDetail
-
createSpecificItemVariantPriceInfo
-
getPriceInfoForSpecificChoiceWithOverride
protected PriceInfo getPriceInfoForSpecificChoiceWithOverride(@NonNull @NonNull SpecificItemChoiceDetail specificChoice) - Parameters:
specificChoice
-SpecificItemChoice
for which to create aPriceInfo
- Returns:
- a
PriceInfo
for aSpecificItemChoice
that has aSpecificItemChoice.getOverridePrice()
.
-
createPriceInfoSpecificChoiceWithoutOverride
protected PriceInfo createPriceInfoSpecificChoiceWithoutOverride(@NonNull @NonNull SpecificItemChoiceDetail specificChoice, @Nullable PriceInfo itemChoicePriceInfo) Creates aPriceInfo
for aSpecificItemChoice
that does not have aSpecificItemChoice.getOverridePrice()
.- Parameters:
specificChoice
-SpecificItemChoice
for which to create aPriceInfo
itemChoicePriceInfo
- ThePriceInfo
of the parentItemChoice
- Returns:
- a
PriceInfo
for aSpecificItemChoice
that does not have aSpecificItemChoice.getOverridePrice()
.
-
createPriceInfoForSpecificItem
protected PriceInfo createPriceInfoForSpecificItem(@NonNull @NonNull Map<String, javax.money.MonetaryAmount> pricingFields, boolean isOnSale) Creates aPriceInfo
withPriceTypeDetails
appropriate for aProduct
,Variant
, or similar entity. Normally, this means that it will look at the pricing fields of aVariant
orProduct
; however, the method has been generalized to take in any number of arbitrary pricing fields.- Parameters:
pricingFields
- An arbitrary set of pricing fields. By default the keys should match the values ofDefaultPriceType
.isOnSale
- Whether the item is on sale.- Returns:
- a
PriceInfo
withPriceTypeDetails
appropriate for aProduct
,Variant
, or similar entity
-
createPriceInfoForCustomSpecificItem
protected PriceInfo createPriceInfoForCustomSpecificItem(@NonNull @NonNull SpecificItemChoiceDetail specificItemChoice) Extension point for creating aPriceInfo
for aSpecificItemChoiceDetail
ifits type
can be more thanDefaultSpecificItemChoiceType.PRODUCT
orDefaultSpecificItemChoiceType.VARIANT
when it and its parentItemChoice
have nooverridePrices
.- Parameters:
specificItemChoice
- TheSpecificItemChoiceDetail
for which to make aPriceInfo
- Returns:
- A
PriceInfo
for aSpecificItemChoiceDetail
when neither it nor its parentItemChoice
haveoverridePrices
.
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-