Search in sources :

Example 6 with DynamicSkuPrices

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;
}
Also used : Money(org.broadleafcommerce.common.money.Money) DynamicSkuPrices(org.broadleafcommerce.core.catalog.service.dynamic.DynamicSkuPrices)

Aggregations

DynamicSkuPrices (org.broadleafcommerce.core.catalog.service.dynamic.DynamicSkuPrices)6 Money (org.broadleafcommerce.common.money.Money)5 ClonePolicyCollectionOverride (org.broadleafcommerce.common.extensibility.jpa.clone.ClonePolicyCollectionOverride)2 BroadleafCurrency (org.broadleafcommerce.common.currency.domain.BroadleafCurrency)1 SkuPriceWrapper (org.broadleafcommerce.core.catalog.domain.pricing.SkuPriceWrapper)1 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)1 DiscreteOrderItemFeePrice (org.broadleafcommerce.core.order.domain.DiscreteOrderItemFeePrice)1