Try our conversational search powered by Generative AI!

Override price used for discount calculation

Vote:
 

Version:

Commerce: 13.22.0

CMS: 11.17.0

I am trying to have custom logic determining which price the promotion engine will use when calculating the discount for a promotion. The site has both anonymous B2C users and logged in B2B users.

I have followed Erik Norbergs suggestion of implementing my own IPriceService. I am able to hit my service when calling GetPrices(MarketId market, DateTime validOn, IEnumerable<CatalogKey> catalogKeys, PriceFilter filter) elsewhere in my solution, so my custom service is registered correctly and intercepted as expected.

However, during _promotionEngine.Run I never hit my custom implementation of GetDefaultPrice which I was under the impression would be the price used by the promotion engine.

Currently we have a huge cluttered piece of logic using inmemoryordergroups which I would like to move away from if possible. These are the requirements that I am trying to implement. 

For B2B:

If a promotion does not have coupon code: The discount should be calculated from the list price. (AllCustomer price) I assume this is the standard functionality.

If a promotion has coupon code: The discount should be calculated from the customer specific price.

I want to keep the rest of the promotion engine logic like redemptions, exclusions etc.

For B2C:

Out of the box functionality which works just fine.

Any input is welcome.

#227692
Sep 10, 2020 9:22
Vote:
 

I think you may need to create a custom implemementation for the ILineItemcalcultor, in your case propably the GetDiscountedPrice method. If I remember correctly the promotionengine uses the calculators and not the priceservice directly

#227828
Sep 14, 2020 7:37
* 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.