Having upgraded from Commerce v8.16.1 to v12.10, I am seeing some issues regarding the application of discount codes (we're using the legacy promotion system still).
Having followed through the code comparing it to the process of the original. It seems that after running the 'cart.RunWorkflow' method, where the workflow passed as a parameter is 'ValidateCart', the discount has not been applied in the OrderForm post-workflow.
The code looks like this (removed some unimportant parts for brevity) -
var ch = new CartHelper(Cart.DefaultName);
var matchedDiscount = PromotionManager.GetPromotionDto()
.Where(x => x.CouponCode == code)
messages += RunWorkflowAndReturnFormattedMessage(ch.Cart, OrderGroupWorkflowManager.CartValidateWorkflowName);
With the event method doing the following -
public static string RunWorkflowAndReturnFormattedMessage(Cart cart, string workflowName)
if (cart == null)
var returnString = string.Empty;
cart.ProviderId = "FrontEnd";
var results = cart.RunWorkflow(workflowName);
var resultsMessages = GetWarningsFromWorkflowResult(results);
var enumerable = resultsMessages as string ?? resultsMessages.ToArray();
returnString = enumerable.Aggregate((current, result) => current + (result + ""));
if (returnString.IndexOf("exception") >= 0)
returnString = ValidationMessage.Error;
else if (returnString.Contains("lineitemremoved"))
returnString = ValidationMessage.StockChange;
else if (!string.IsNullOrEmpty(returnString))
returnString = ValidationMessage.Other;
catch (Exception aore)
Is there anything obvious I've missed, it was a large upgrade so there's a chance I've missed some kind of breaking change/rework?
Are you using the new promotion system or the old one?
It might have something to do with the breaking changes in version 11:
@Jafet, The OP mentions that he is using the legacy promotion system still. @James, To follow up on Jafet's comments, did you review this part of that page in particular: "New promotion system enabled by default"?
Ah, read a bit too quickly it seems. :)
So yeah, @James, take a look at that section, if you haven't already.
Ah, that was the issue. I was aware of it but I'd only added that config section to the config of CommerceManager. It's now in both CM and Web and looks to be applying discounts.
Thanks for the push in the right direction guys!