I have created a new condition for a promotion in our Sitecore Commerce site following this example. Is it possible to get cart details or the session id inside the evaluate method?

The evaluate method is triggered when user clicks on the 'apply promo' button in UI.

namespace Sitecore.Feature.Commerce.Promotions.Engine.Conditions
    using Microsoft.ApplicationBlocks.Data;
    using Sitecore.Commerce.Plugin.Carts;
    using Sitecore.Framework.Rules;
    using System;
    using System.Data;
    using System.IO;
    using System.Web;
    using System.Web.Configuration;

    [EntityIdentifier("Future Event Dates")]
    public class FutureEventDatesCondition : ICartsCondition, ICondition, IMappableRuleEntity
        public IRuleValue<string> FutureEventStartDate { get; set; }
        public IRuleValue<string> FutureEventEndDate { get; set; }

        public bool Evaluate(IRuleExecutionContext context)
           //how to get the cartid or sessionid in here           

We are using Sitecore Commerce 8.2.1.

1 Answer 1


@RobEarlam from slack helped me with the solution.

The cart details can be accessed like this inside the Evaluate method.

public bool Evaluate(IRuleExecutionContext context)
  CommerceContext commerceContext = context.Fact<CommerceContext>((string)null);
  List<Cart> lstCarts = commerceContext.GetObjects<Cart>();
  Cart cart = lstCarts[0];

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.