You can always use the _promotionEngine.Evaluate call and calculate the discount from the RewardDescription.SavedAmount yourself.
The correct discounted price should be the price minus the saved amount, no?
var discountedPrice = price - _promotionEngine.Evaluate().Sum(r=>r.SavedAmount);
Hi Erik
That seems to work, but this leads me to a new question.
Is there any way to get the discounted price for a variation for a specific visitor group, without actually being in the group?
To elaborate, we have a scheduled job that replicates our products to ElasticSearch (for searching). In this scheduled job i need to get a specific visitor groups price, as well as the normal price.
I'm sorry Mads, I have nothing but bad news for You.
We have run into the exact same issue, the promotionengine always uses HttpContext.Current when evaluating.
We have a ticket registered with Episerver developer support and they have made a bug for it #COM-4431.
However it is still not visible in the bug list: http://world.episerver.com/support/Bug-list/
So the status is unknown, We do not know when a solution will be forthcoming.
Erik Norberg
We have a ticket registered with Episerver developer support and they have made a bug for it #COM-4431.
However it is still not visible in the bug list: http://world.episerver.com/support/Bug-list/
So the status is unknown, We do not know when a solution will be forthcoming.
Good to hear! I created a feature request for something similar but got no response.
A way to pass in a contactId or visitor group to the promotion engine would be awesome.
My request:
http://world.episerver.com/forum/developer-forum/Feature-requests/Thread-Container/2017/5/commerce-enable-promotion-system-to-look-at-purchaseorder-data-when-applying-discounts/
I am not entirely sure but I automatically repel at the sight of them setting a static property for the current visitor group name, it makes me suspect the risk of some really hairy threading issues.
Getting customer specific prices would mean a lot of calls to evaluate with different values of the visitor group...
If you only have the one visitor group I guess you can get it to work thou.
Hi
{ variation.ContentLink }, currentMarket, currentMarket.DefaultCurrency, _referenceConverter, _lineItemCalculator);
I am currently implementing visitor group based campaigns / promotions on our site, but have gotten some odd results from the promotionEngine.
I have a campaign, which is limited to a single visitor group, this campaign has a single entry promotion (BuyQuantityGetItemDiscount).
Calling the
_promotionEngine.GetDiscountPrices( new List
yields no results.
But calling the
_promotionEngine.Evaluate(variation.ContentLink, currentMarket, currentMarket.DefaultCurrency, RequestFulfillmentStatus.Fulfilled)
yields the wanted rewardDescription.
When placing the item in a cart (thus calling the cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings()); ) the unit price is correctly calculated if and when being in the correct visitor group, but since I need to show the correct (discounted) price for the current user (based on the users visitor group), i need to get the users discounted price for the variation.
/Swensson