on ‎2019 Apr 05 11:48 AM
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.
Request clarification before answering.
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;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.