Previously, doing such this was difficult, but the combination of these new enhancements enables you to forecast such an action against the promotion engine.
An example, forecast shipping promotions prior to selecting any shipping method.
We were recently faced with the challenge of presenting all customers with their potentially upcoming shipping promotional values, forecasted based on available shipping options, throughout the e-Commerce experience. In order to qualify for a shipping promotion in the out-of-the-box promotion experience, the customer has to have a given shipping method associated to his/her order. When forecasting promotional values, that’s what you are mimicking to give the customer insights in to the promotions he or she would qualify to in given situations.
private void ForecastPromotionsForSelectingShippingMethod(ICart cart, ShippingMethodDto.ShippingMethodRow shippingMethodRow)
//Create a memory order to not intefer with our cart
IOrderGroup memoryOrderGroup = new InMemoryOrderGroup(((SerializableCart)cart).DeepClone() as IOrderGroup);
IShipment shipment = memoryOrderGroup.GetFirstShipment();
shipment.ShippingMethodId = shippingMethodRow.ShippingMethodId;
//Run promotions against memory order and see if we would get discount
IEnumerable<RewardDescription> rewards = this._promotionEngine.Run(memoryOrderGroup);
foreach (RewardDescription reward in rewards)
//Do something with the rewards user will get if he/she selects the Shipping Method
As you can see in above snippet, the “secret” is to use Episerver’s InMemoryOrderGroup to apply potential action to. It ensures that the user’s shopping cart stays untouched and you can thereby do all the promotion experiments in the world. My snippet enables you to retrieve the qualified rewards as if the user had selected a given shipping method.