November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi,
I don't think there's an easy, ready-to-use method which does exactly what you want but you could probably calculate the difference yourself by running the promotions engine against the cart, looking through all of the unfulfilled promotions for the free shipping promotion then looking at the minimum spend configured for that promotion in the current currency. A simple example might look something like this (though you'd probably want to inject the IPromotionEngine rather than using ServiceLocator):
var rewards = ServiceLocator.Current.GetInstance<IPromotionEngine>().Run(cart, new PromotionEngineSettings(RequestFulfillmentStatus.PartiallyFulfilled | RequestFulfillmentStatus.NotFulfilled, false));
foreach (var reward in rewards)
{
if (reward.Promotion is EPiServer.Commerce.Marketing.Promotions.SpendAmountGetFreeShipping freeShippingPromotion)
{
var cartSubTotal = cart.GetSubTotal();
var threshold = freeShippingPromotion.Condition.Amounts.FirstOrDefault(x => x.Currency == cart.Currency);
if (threshold > 0)
{
var additionalSpendRequiredToGetDiscount = threshold - cartSubTotal;
}
}
}
One word of caution though - that's probably quite a resource intensive bit of code so I'd use it sparingly.
Hi,
We have "Spend for Free Shipping" discount set on out website and we want to show information how much money customer need to add to the cart to get free shipping. Is there a way to get this information using ICart object?