Get discounted price for customer with special price when item is in a campaign? [Commerce 12.16]

Vote:
 

Hi!

I have a customer that belong to a specific customer group. That customer group has a special price on an item. We then have a campaign that gives 40% discount on that special item.

The item costs 100kr and if a non logged in customer looks at the item they see a price of 60kr.
I use this line of code:

var discountPrices = _promotionEngine.GetDiscountPrices(variant.ContentLink, _currentMarket.GetCurrentMarket(), _currencyService.GetCurrentCurrency());

That gives me a price of 60kr.

If I login with the customer that has a special price he sees the same price 60kr, but if he adds it to the cart he gets 40% on his special price which is 80kr so his price in the cart is correctly 48kr. 40% discount 80kr.

How do I do to show the price of 48kr right away when he looks at the product? I cannot find an overload to GetDiscoutnPrices that considers diffent price types, customer pricing?

If i to this:

var priceFilter2 = new PriceFilter
{
    Currencies = new List<Currency> { currency },
    CustomerPricing =
        new List<CustomerPricing>
        {
            new CustomerPricing(CustomerPricing.PriceType.PriceGroup, _currentContactFacade.CustomerDiscountGroup)
        }
};

var p = _pricingService.GetPriceList(variationCode, market.MarketId, priceFilter2);

That will give me a price of 80kr.

Is there a way for me to get the price of 48kr?

Thanks!

/Kristoffer

#210604
Nov 29, 2019 14:06
Vote:
 

There is unfortunately, no easy way to do it. You can technically implement your own IPromotionEngine (or rather, intercept it), and implement Evaluate so you can create an in memory order group with that price. it's probably easier to inherit from PromotionEngineContentLoader and override TryGetDefaultPriceAmount. However PromotionEngineContentLoader is a class in internal namespace so that's a risk you have to take 

#210608
Nov 29, 2019 14:26
Vote:
 

Ok, then I know what to do. I will update my customer. I think they are more into that customers with special price should be excluded from specific campaigns and that can be solved with visitor groups or something.

Thanks Quan!

/Kristoffer

#210609
Nov 29, 2019 14:33
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.