Could you please suggest how to get the promotion details for a specific coupon? For example, I want to show discount value (in percent) for the cart, so I need to get this value from commerce engine side. I looked through the components, policies and context objects in debug mode (used a custom block in IApplyPromotionsBenefitsPipeline, ICalculateCartLinesPipeline, ICalculateCartPipeline pipelines), but I couldn't detect any useful object.

P.S. I know that there is a similar question , but it doesn't work for me (wrong context? wrong entity class?).

Thank you in advance for the help.

1 Answer 1


If you want to calculate the discount value for the cart by yourself, you can use the below code snippet:

  1. In the web project, CartLine has CommerceTotal entity which provides you Discount information at Line Item as well as Order level.
    var cartEntity = (Cart)cart;
    var TotalDiscount = (cartEntity.Lines.Sum<CartLine>((Func<CartLine, Decimal>)(lineitem => ((CommerceTotal)lineitem.Total).LineItemDiscountAmount)) + ((CommerceTotal)cartEntity.Total).OrderLevelDiscountAmount);

Example: https://github.com/techduggu/Sitecore.Commerce.Coupons/blob/master/Commerce/Models/CartModel.cs#L28

  1. If you want to achieve the same in Commerce engine project, you can use AwardedAdjustment property (of type: CartLineLevelAwardedAdjustment) of CartLineComponent. It is the only entity which will be set by associated Benefit Action to populate the information about Promotion, Promotion Cart Text, Discount Amount, Adjustment Type etc. An example of Benefit action setting this information is: https://github.com/techduggu/Sitecore.Commerce.Coupons/blob/master/Sample.Plugin.Promotions/Actions/CustomPercentOffAction.cs#L83

You can use the above Promotion Plugin project for code reference. It displays the Discount value of Cart on Checkout page. Hope it helps!

  • Hi! Thank you for the suggestion. Will test it this week and will return with a feedback.
    – Max
    Jan 15, 2020 at 10:38
  • Cool. Let me know if it helps/solves your problem or you may also vote it. Jan 16, 2020 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.