We have configured Sitecore Commerce with a number of Promotions. One of them looks like this:
And the promotion code works fine. If added to the basket, the benefits of the promotion kick in and the basket total reflects this.
But my question is; how can I access the properties of this promotion in the .Adjustments collection on my cart?
Currently I have this bit of code:
var firstPromotion = cart.Adjustments.First();
if (firstPromotion != null)
{
model.PromotionsApplied = true;
model.AppliedPromoText = firstPromotion.Description;
model.AppliedPromoResult = firstPromotion.Amount.ToCurrency(cart.Total.CurrencyCode);
if (!firstPromotion.IsCharge)
{
model.AppliedPromoResult = new HtmlString("-" + model.AppliedPromoResult);
}
}
The problem is; .Description does not give me the expected "Description" field from the promotion itself. And as for the other properties, "Text" and "Cart Text" - these are not mapped to the Adjustments object I get back.
I am assuming I could possibly get these properties via the GetPropertyValue
method. But if so, what would these be named? Or can the Adjustment
be cast as a more specific entity like maybe PromotionAdjustment
?