use of org.broadleafcommerce.core.catalog.service.dynamic.DynamicSkuPrices in project BroadleafCommerce by BroadleafCommerce.
the class SkuImpl method getRetailPriceInternal.
/*
* This allows us a way to determine or calculate the retail price. If one is not available this method will return null.
* This allows the call to hasRetailPrice() to determine if there is a retail price without the overhead of an exception.
*/
protected Money getRetailPriceInternal() {
Money returnPrice = null;
Money optionValueAdjustments = null;
if (SkuPricingConsiderationContext.hasDynamicPricing()) {
// We have dynamic pricing, so we will pull the retail price from there
DynamicSkuPrices dynamicPrices = SkuPricingConsiderationContext.getDynamicSkuPrices(this);
returnPrice = dynamicPrices.getRetailPrice();
optionValueAdjustments = dynamicPrices.getPriceAdjustment();
if (SkuPricingConsiderationContext.isPricingConsiderationActive()) {
return returnPrice;
}
} else if (retailPrice != null) {
returnPrice = new Money(retailPrice, getCurrency());
}
if (returnPrice == null && hasDefaultSku()) {
// Otherwise, we'll pull the retail price from the default sku
returnPrice = lookupDefaultSku().getRetailPrice();
optionValueAdjustments = getProductOptionValueAdjustments();
}
if (returnPrice != null && optionValueAdjustments != null) {
returnPrice = returnPrice.add(optionValueAdjustments);
}
return returnPrice;
}
Aggregations