cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cart level promotions and Global discounts. 6.6

Former Member
0 Likes
286

Hi,

We have a requirement where we need to display which promotion gave how much discount on cart. Some how I managed to map Global discounts and appliedOrderPromotions. But now the challenge I am facing is, In case of a promotion having a free gift or free coupon in conditions, There will not be entry in globalDiscounts. Hence my logic is failing.

Please suggest your best solutions to display Promotion and its appliedDiscount(the amount reduced from cart total) value on cart.

Accepted Solutions (0)

Answers (1)

Answers (1)

Hello there,

Here is code example that will give you all the applied Promotions in an order based on the ReportPromotionService (This is the service that is displaying promotions of an order on the backoffice)

 private List<PromotionEngineResult> parsePromotions(OrderModel order) {
     List<PromotionEngineResult> allAppliedPromotions = new ArrayList<>();
     // Remember to inject the Report Promotion Service
     final PromotionEngineResults promotionEngineResults = getReportPromotionService()
         .report(order);
     // this list Contains all the applied promotion on entries
     final List<OrderEntryLevelPromotionEngineResults> orderEntryPromotionEngineResults = promotionEngineResults
         .getOrderEntryLevelPromotionEngineResults();
     
     final OrderLevelPromotionEngineResults orderPromotionEngineResults = promotionEngineResults
         .getOrderLevelPromotionEngineResults();
 
     if (CollectionUtils.isNotEmpty(orderEntryPromotionEngineResults)) {
       orderEntryPromotionEngineResults.stream()
           .map(AbstractPromotionEngineResults::getPromotionEngineResults)
           .forEach(allAppliedPromotions::addAll);
     }
 
     if (orderEntryPromotionEngineResults != null) {
       allAppliedPromotions.addAll(generatePromotionResults(orderPromotionEngineResults, order));
     }
     return allAppliedPromotions;
   }