We have a website built on Sitecore commerce and working on the following requirement.

When user applies a promo/coupon code at checkout, validate the code with a third party system. Is it possible to get the promo code that user has applied, in the IRuleExecutionContext.

I'm aware of creating a custom condition with the Evaluate method. But do not know how to get the applied code here.

Using Sitecore 8.2 update 5 with Sitecore Commerce 8.2.1 update 3

1 Answer 1


For me it's not a good idea to validate coupon code with a third party system when it was applied for a cart.

You need to validate it on Add coupon to cart.

Try to find IAddCouponToCartPipeline, which has AddCouponToCartBlock. You can replace AddCouponToCartBlock with your custom and add your check before:

public override async Task<Cart> Run(CouponArgument arg, CommercePipelineExecutionContext context)


      if (!IsYourCouponValid(arg.CouponCode))
        string str = await context.CommerceContext.AddMessage(context.GetPolicy<KnownResultCodes>().ValidationError, "CouponNotValid", new object[1]
        }, string.Format("Coupon {0} is not valid.", arg.CouponCode));
        return cart;
      cart.GetComponent<CartCouponsComponent>().List.Add(new CartCoupon()
        CouponId = arg.CouponCode,
        Promotion = couponDefinition.Promotion
      return cart;

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.