Developer forum

Forum » Development » Override method for converting price to another currency

Override method for converting price to another currency

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Is there a method we can override after the price has been converted to the site's currency?

 

We are overriding FindPrice when we're adding a markup on certain situations and this works great for the most part. We noticed that the FindPrice returns the price in the default currency (USD), but we need to do our custom code after it's been converted to a different currency (EUR)

 

Our problem is roundings. The customer always wants rounding up. Here's our scenario

  • Product price in USD: 303
  • Markup: 2 (303 x 2 = 606)
    • (Our customization returns 606)
  • Euro currency rate: 125
  • Price in Euro: 606 / (125/100) = 484.8
  • Price in Euro with rounding (up): 485

 

The expected outcome:

  • Product price in USD: 303
  • Euro currency rate: 125
  • Price in Euro: 303 / (125/100) = 242.4
  • Price in Euro with rounding (up): 243
  • Markup: 2 (243 x 2 = 486)

 

So essentially we need to move our logic out of FindPrice into something further in the stack after Dynamicweb has converted to Eur. I'm attaching our custom code to help make sense of it.

 

How can I do that?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

The price provider gets a currency as a parameter - so if you return a EUR price, it will not convert it from US to EUR...

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Perfect. worked like a charm. I had to do the conversion between rates "by hand" since there is no public method in services to do that, but it's basic math, but then I used the Round() method ;)

 

Thanks,

Nuno Aguiar

 

You must be logged in to post in the forum