November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Anton,
Try this:
var InMemoryOrderGroup = new InMemoryOrderGroup(cart);
var rewardDescription = InMemoryOrderGroup.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings(RequestFulfillmentStatus.Fulfilled, true));
This will copy you cart to an in memory one. Combined with the PromotionEngineSettings you'll be able to see what discount is being applied.
You can get the placed price and the discounted price from the rewardDescription OR the InMemoryOrderGroup from the code above.
This is how you can do it
public IEnumerable<RewardDescription> Evaluate(IEnumerable<ContentReference> entryLinks,
IMarket market,
Currency currency,
string couponCode,
RequestFulfillmentStatus requestFulfillmentStatus)
{
Validator.ThrowIfNull("entryLinks", entryLinks);
Validator.ThrowIfNull("market", market);
var rewardDescriptions = new List<RewardDescription>();
var promotionEngineSettings = new PromotionEngineSettings() { ApplyReward = false, RequestedStatuses = requestFulfillmentStatus };
foreach (var entryLink in entryLinks)
{
var orderGroup = _promotionEngineContentLoader.CreateInMemoryOrderGroup(entryLink, market, currency);
orderGroup.Forms.First().CouponCodes.Add(couponCode);
var entryLinkRewardDescriptions = _promotionEngine.Run(orderGroup, promotionEngineSettings);
rewardDescriptions.AddRange(entryLinkRewardDescriptions);
}
return rewardDescriptions;
}
Is there anyway to evaluate a promotion for a single entry but with a couponcode applied?
Say i want to compare the price given by the coupon-discount and another price.
Or if i want to display "Price with coupon REA2022: 650kr 800kr".
Commerce v.13.31