In the old engine, promotion is sticked with LineItem and it is easy to get it by calling LineItem.Promotion property.
In the new engine, we can't get promotion like that as it is applied and stored in different way (IOrderForm.Promotions).
You have to satisfy the following conditions, then that would be fairly easy in the new promotion system to find promotions applied to a lineitem
1. Have no duplicated lineitem in same order form
2. Entry level promotions are considered.
if the conditions above are satisfied, you can get back the information like this:
var appliedPromotionGuids = orderForm.Promotions.Where(p =>
p.Entries.Any() &&
p.Entries.Any(c => c.EntryCode.Equals(lineItem.Code, StringComparison.OrdinalIgnoreCase))).Select(p => p.PromotionGuid);
var promotions = appliedPromotionGuids.Select(p => _contentLoader.Get<PromotionData>(p));
Please sign in to leave a comment.