Try our conversational search powered by Generative AI!

Evaluate discount unit price for SKUs on promotion


Commerce 12.8

I have a scenario where I have long running item promotions e.g.

Buy at least 3 items and get 25% off

On the website page I need to list all the SKUs with the default unit price and the discounted unit price when buying 3+ items

What's the best (and simplest) way to get the discounted price from the PromotionEngine in this case ? The IPromotionEngine interface doesn't accept quantity as a parameter to preload the discount prices


Edited, Oct 26, 2018 5:37

What Evaluate does is to create an in memory order group with one item and with quantity = 1.0m and use the promotion engine to see which promotions can be applied. You can do the same with different quantity. Yes InMemoryOrderGroup is in an internal namespace so remember it might be changed without a major version 

Oct 26, 2018 8:45

Hi Quan, thanks for responding

How do I pass quantity to the IPromotionEngine.Evaluate method ? Can you please provide a code example


Oct 26, 2018 8:55

When you have an order group you can just call Run, but with this setting 

new PromotionEngineSettings() { ApplyReward = false, RequestedStatuses = requestFulfillmentStatus };

Oct 26, 2018 9:22

Not ideal that InMemoryOrderGroup is intended for internal use only but seems the only way to preview applicable promotions with quantity conditions

Quan, is there any performance concerns by calling Run for individual SKUs on a listing page to preview discount prices ? 


Oct 26, 2018 11:41

I'm glad you asked. It should not be worse than you run Evaluate, the actual question is if you have any heavy promotion processor. If all of your processors are fast, then it should not be a problem. (still CPU heavy, but not that bad) 

Oct 26, 2018 11:49

At this stage only using builtin promotions 

Thanks for your help

Edited, Oct 26, 2018 11:59
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.