How to get discounted price for products in an order?

Hi!
I have a scenario where I need to fetch information about every product in an order, for example, the discounted price for every product in the order. If I use the SalesOrder and from there retrieve information for every SalesOrderRow I can get data for every row. However, I’m not sure how to get the price for every product if campaigns and/or discounts are applied.

I’m aware that I can check the OrderRowType but I don’t know if it will work in all situations? For example, if an order contains two or more of the same product type it seems that the discount amount will show up in one row. Is it safe to assume that the amount can be divided by the quantity in these situations? If there is a percentage discount for every product it won’t work to divide the discount amount by quantity, but I don’t know if this can happen or if discounts and campaigns that are based on percentage will show up in a different way?

When reading this page: Discounts, I’m wondering if I should use DiscountInfo, but I don’t know how to do this in an easy way from the SalesOrderRow?

Anyway, my main question: What’s the easiest way to get price information for products in an order, considering campaigns and discounts?

Litium version: 8:10.0

I’m not sure if this is the easiest way, but it’s one way.

On the DiscountInfo you can get the ResultOrderRowSystemId which is representing the discount SalesOrderRow.

So either you get the SalesOrderRow from the DiscountInfo

var discountRow = salesOrder.Rows.FirstOrDefault(x => x.SystemId == discountInfo.ResultOrderRowSystemId);

Or if you get the DiscountInfo from the SalesOrderRow

var discountRow = salesOrder.Rows.FirstOrDefault(x => x.OrderRowType == OrderRowType.Discount);
var discountInfo = salesOrder.DiscountInfo.FirstOrDefault(x => x.ResultOrderRowSystemId == discountRow.SystemId);

Then to match the DiscountInfo to the product rows in SalesOrderRows you’ll have to check DiscountInfo.SourceOrderRowSystemIds which is telling you what product rows are affected by the DiscountInfo.

If the DiscountInfo.SourceOrderRowSystemIds contains the same item multiple times, that is because we adding one reference for each in the used variant.

Example if you have
A) 10% of for product A
B) Buy 3 and pay for 2 for product A

In this case if you have 4 items in the cart you will have the same item 3 times for the discount B in the DiscountInfo.SourceOrderRowSystemIds and 1 time for discount A.

Thank you both for replying! I’ve combined the info from here and the documentation, and I examined how discounts are applied in the cart in the tutorial accelerator. I think what I have will work (although some more testing is needed before I know for sure).

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.