We are on commerce 11.4, but have not migrated to the new order system.
I was wondering if it was possible to use the old order system (with CartHelper) with the new promotion system (where you set campaigns etc. under the "Marketing" tab)?
So far I am unable to apply any created item discounts to the cart. I thought it would be done automatically under-the-hood of EpiServer, but even after removing all of our custom workflows the full price of an item is added to the cart rather than the sale price.
I know the promotion was created properly because I can see the correct discount price when using:
promotionEngine.GetDiscountPrices(variation.ContentLink, currentMarket.GetCurrentMarket(), organization.GetPreferredCurrencyCode())
I've tried adding this code when adding to the cart:
promotionEngine.Run((IOrderGroup)cartHelper.Cart, new EPiServer.Commerce.Marketing.PromotionEngineSettings());
I've tried adding the following to the ecf.app.config file:
But the above didn't work.
If I add back in our custom workflow stuff hooked into CartValidateWorkflow, the lineItem.Discounts is empty from the lineItem from the orderForm.
I have also tried cloning the latest version of the QuickSilver repo that still had the old order system (7c4f5afccd9966c68fe65872f6456a5cde64379a on August 12), however this commit unfortunately is uses the old promotion system.
Any advice would be greatly appreciated!
I can be wrong here, but the new promotion system does not know or care about CartHelper. As long as you have a valid cart which satisfies the conditions, it should apply. However:
Note that CartHelper is obsoleted in Commerce 11.6.1, and we recommend to use the new APIs as soon as possible.
Thanks for your response. Would you still expect there to be any Promotions on the orderform if we only have item discounts?
They have a shipment I believe. My only hope right now might be to add the use of promotionEngine.GetDiscountPrices to a custom workflow and recalculate the total and line item prices within it but I am reluctant to do that.
Is there anything else that it could be?
Yes, IOrderForm.Promotions will contain everything, including entry, shipment or orderfrom promotion information.
The builtin workflows were already upgraded to use the new promotion system internally if you configure to use it. Just to make sure that you have the settings in both CMS site and Commerce Manager site.
Ah I accidentally hadn't configured it in both sites, only the Commerce. Now the line item promotion shows up on the IOrderForm!
However with WorkflowsVNext enabled to get that working, the following code does not work anymore
It is calling the default EpiServer CartPrepare workflow, and the line items in the cart are all removed when it is run, can you explain that?
If you use OrderGroupWorkflowManager to run the workflow, it should return a WorkflowsResult which contains warnings/reasons on why lineitems were removed. In your case it's likely that the lineitems were not in a shipment.