9

We have configured Sitecore Commerce with a number of Promotions. One of them looks like this:

enter image description here

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.

enter image description here

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?

3

It's not a bug, it's an undeveloped feature.

At least that is the answer I got from Sitecore support. So the core issue is; .Description is actually intended to give you the "Cart Text" content. So you don't really need to access other properties (although I would still consider this to be convenient) - this is all taken care of for you.

The problem is; the Pricing and Promotion Manager UI (the SPEAK application) only works on the "en" language. You cannot switch language in any way (short of creating new user accounts and changing their content editing language) - so when you request .Description in a site running anything other than "en" you just get the default text back.

And this was, what was throwing me off course on this.

Sitecore Support did provide me with a workaround for this, but it has no public reference number (since it's not a "bug"). Refer to ticket 498830 if you need this issue solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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