cancel
Showing results for 
Search instead for 
Did you mean: 

Multiplicative application of discounts

Former Member
0 Kudos

Is it possible through configuration or other means, to force the price calculation to be multiplicative instead of the default behavior? What I mean is this:

We have a cart with one Product, totalPrice of 100€ Now we have two discounts applied, both 20%. The behavior now seems to be to cumulate the discounts like this:

 100€ - (20% + 20%) = 60€

Pretty straightforward. But now we want this:

 100€ - (20% of 100€) = 80€
 80€ - (20% of 80€) = 64€

I couldn't find anything in the documentation on how to change this. What would be the easiest, least intrusive way to solve this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Brief research reveals you can't do this by configuration, you need to customize the cart calculation.

Here's some starting point to research and customize this:

  • The DefaultCalculationService uses DiscountValues to calculate. It seems to me that they already have a the calculated value of the percent discount. Then the DefaultCalculationService does not convert relative discounts to a value.

  • That means the value is calculated elsewhere and that is in findDiscountsStrategies injected via Spring

  • There is two such strategies injected:

           <property name="findDiscountsStrategies">
                 <list>
                     <ref bean="currentFactoryFindPricingStrategy"/>
                     <ref bean="findOrderDiscountValuesStrategy"/>
                 </list>
             </property>
     
    
    
  • The second ignores entry discounts, it only takes care of order level discounts. So you need to check what currentFactoryFindPricingStrategy does:

       @Override
         public List<DiscountValue> findDiscountValues(final AbstractOrderEntryModel entry) throws CalculationException
         {
             final AbstractOrderEntry entryItem = getModelService().getSource(entry);
             try
             {
                 return getCurrentPriceFactory().getDiscountValues(entryItem);
             }
             catch (final JaloPriceFactoryException e)
             {
                 throw new CalculationException(e);
             }
         }
     
    

It asks the Europe1PriceFactory for the DiscountValues. That you need to check with a decompiler 😉

Somewhere here you need to change the behavior how relative discounts are converted to values.

I would suspect that they are individually converted against the base price of the product and the discounted price is not taken into account. So you need to find the place where this happens and change the behavior to use the discounted price for each new discount.

Answers (0)