Hi Jay,
The total value of all discounts applied in an Order is not stored by default.
One option other than parsing the summary XMLs of the order items and the order itself (as we have different types of discounts) could be to supply a custom calculator into the pipeline. That would calculate the total discount along the calculation pipeline run and store this into custom property, which would then be saved with an OrderInfo.
However, going through the summary XML data appear to be likely easier. You could use already available classes and methods:
ValuesSummary constructor (accepting summary XML) and the Sum method to get the sum for various discounts:
var orderDiscountSummary = new ValuesSummary(orderInfo.OrderDiscounts);
decimal orderDiscountsTotal = orderDiscountSummary.Sum(i => i.Value);
Please note that there is also the OrderInfo.OrderOtherPayments summary with "Gift cards" application,
Moreover, each OrderItemInfo has its own summary about unit-level discounts and the item-level discounts application, which you may want to incorporate in the total.
in the loop through all OrderItemInfo objects for the given Order, it could look like:
var productDiscountsSummary = new ValuesSummary(orderItem.OrderItemProductDiscounts);
decimal productTotalDiscount = productDiscountsSummary.Sum(i => i.Value) * orderItem.OrderItemUnitCount;
var itemDiscountsSummary = new ValuesSummary(orderItem.OrderItemDiscountSummary);
decimal itemTotalDiscount = itemDiscountsSummary.Sum(i => i.Value);
decimal orderItemTotalDiscount = productTotalDiscount + itemTotalDiscount;
Obviously, you may need to adjust the value currency if it differs from main and you want to compare in main.
Please let me know if this helps.
By the way, for a different direction (and possibly requirement), my colleague wrote an article earlier about creating reports of applied discounts for Orders at
https://devnet.kentico.com/articles/creating-reports-for-discounts
Best regards,
Zdenek