cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple discountValue Guid at order entry level issue

Former Member
0 Kudos

We have an issue In Production with few orders in which get 50% discount on Product if Price > 49.99 for qualifying Products . Order contains 7 items . Out of these 7 products , 2 items have multiple discountValue (means discount applied twice and thrice) . When we tried to search RuleBasedPromotionAction for these Action guid from flexi query , we didnt find any RuleBasedPromotionAction for extra discountValues. As a result of this issue , after discount few products are in negative Price .

We are not able to replciate this scenario in lower environment . Please help us on this . We are using hybris 6.6 .

Thanks, Nikhil.

Accepted Solutions (0)

Answers (6)

Answers (6)

former_member649260
Discoverer

Actually yes we are deploying a defensive strategy for this soon. Hoping it will fix it and so far testing seems to indicate there is nothing destructive by doing this. We are noticing DiscountValues on order entries do not have Promotion Actions associated to them. You may want to see if you are in a similar situation. Here's the calculation hook we added:

 package com.crossview.hybris.order;
 
 import de.hybris.platform.commerceservices.order.hook.CommerceCartCalculationMethodHook;
 import de.hybris.platform.commerceservices.service.data.CommerceCartParameter;
 import de.hybris.platform.core.model.order.AbstractOrderEntryModel;
 
 public class VddCommerceQuoteCartCalculationMethodHook implements CommerceCartCalculationMethodHook {
     @Override
     public void beforeCalculate(CommerceCartParameter parameter) {
         /*
             This is defensive in that an array of DiscountValues are set on order entries.  When cleaning up promotions
             during a cart recalculation it can somehow misfire and not remove all DiscountValue entries even though all
             associated promotional objects have been cleaned up.  This ensures that orphan DiscountValues are not to be
             calculated into the quote total when recalculation occurs.
          */
 
         if(parameter != null && parameter.getCart() != null && parameter.getCart().getEntries() != null) {
             for (AbstractOrderEntryModel orderEntryModel : parameter.getCart().getEntries()) {
                 orderEntryModel.setDiscountValues(null);
             }
         }
     }
 
     @Override
     public void afterCalculate(CommerceCartParameter parameter) {
         //Do nothing
     }
 }
 
former_member740857
Discoverer
0 Kudos

Is there any way to stop triggering the action twice at order level

former_member649260
Discoverer
0 Kudos

Update: This solved our issue!

former_member649260
Discoverer
0 Kudos

We have had the code above in production for the last 4 days and have not seen the issue since. We usually get a couple a day. So far so good!

0 Kudos

Hi, Did anyone got a solution for this. We have a similar situation where some products were applying discounts twice so, in total we are giving away 75% discount instead of 50% discount.

former_member649260
Discoverer
0 Kudos

Did you ever find a solution to this issue? We get multiple orders per day out of 10,000 or so that currently have this issue. I cannot figure out the reason why after a week or 2 of debugging. I'm thinking of doing some defensive coding after a cart calculation to review the DiscountValues on the order and remove any that don't have a matching promotion action as they don't seem valid. Thanks!