Evaluate discount unit price for SKUs on promotion

Vote:
 

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

Thanks

#198371
Edited, Oct 26, 2018 5:37
Vote:
 

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 

#198388
Oct 26, 2018 8:45
Vote:
 

Hi Quan, thanks for responding

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

Thanks

#198389
Oct 26, 2018 8:55
Vote:
 

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

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

#198391
Oct 26, 2018 9:22
Vote:
 

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 ? 

Thanks

#198401
Oct 26, 2018 11:41
Vote:
 

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) 

#198404
Oct 26, 2018 11:49
Vote:
 

At this stage only using builtin promotions 

Thanks for your help

#198405
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.