Developer forum

Forum » PIM » Calculate prices in other currency than the default one

Calculate prices in other currency than the default one

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a situation where I get product prices in 2 currencies: RON and EUR.

RON is the default currency. I have defined a conversion rate between RON and EUR.
What I need to do now, is always render RON prices in a PIM feed (I am using a custom template).

Prices are stored in the PriceMatrix and I am selecting RON for currency on the feed.

If I try to render the price with product.Price.Price, I get the value in EUR rendered as RON without the conversion.

What would be the best way to render the converted/calculated price?

Thank you,
Adrian


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Anybody?

 
Michael Knudsen
Reply

Hello Adrian,

- shouldn't you select EUR for currency on the feed in order to have the conversion between RON and EUR?

Have you tried with the standard XML template?  Same result?

Br. Michael Knudsen

 
Michael Knudsen
Reply

Hello again,

- tried it on a customer solution, where I expected the prices in RON, since I have the prices in the price-matrix in EUR. But it dosen't work :-| 

Guess you should contact Dynamicweb Care.

PS. I'm using the standard XML feed provider.

Br. Michael Knudsen

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Michael,

It's not that simple :)
I can select ROn and I get prices in RON and I can select EUR and get prices in EUR.

The problem I have is that when selecting the currency, only the price in that particular currency is handled.

In my case, I need to select RON and get all prices that are set in RON and a conversion of the prices defined in EUR. Some products have only RON prices some have only EUR prices.

In the feed, I need to have all products with RON prices. Every product that has prices defined in EUR should be converted to RON.

The feed however, would filter out the Prices list and keep only the prices in the mentioned currency. Which makes it difficult to even try to make the conversion manually in the template.

I guess that I would need some method to get the price for a specific currency and then convert it:

GetPrice(Product, Currency)
CalculatePrice(PriceInfo, SourceCurrency, DestinationCurrency)

I have had some hard time finding something relevant along these lines in the API.

If you have any other idea, I would appreciate it.

Adrian

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

The price matrix will only return prices in the correct currency and then fallback to default price in default currency specified on the product.

You can use PriceManager.GetPrice that takes a pricecontext as a parameter. On the context you can change the currency and get the price back from the price matrix in that currency.

If you do not know if the price is in EUR or in RON, you have to make 2 calls to GetPrice with each currency and then make your decissions from that.

You cansider doing this in a custom priceprovider instead of in the template. Then everywhere a price is needed this will take affect.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you very much for the guidance and suggestions.

Adrian

 

You must be logged in to post in the forum