Currencydropdoenlist - DisplayPrice in MVC doesn't chnag

Posted by Community Admin on 05-Aug-2018 07:52

Currencydropdoenlist - DisplayPrice in MVC doesn't chnage

All Replies

Posted by Community Admin on 14-Aug-2014 00:00

Hi Team,

I have created one MVC widget to show product information, in that I have to show price too.

I tried using following properties to display price value:

DisplayPrice
DisplayPriceFormatted
DisplayPriceWithVatAndSale
DisplayTaxInPrice
Price

But when I change the  Currencydropdoenlist to some other currency, price value doesn't change it remains as it is.

Whereas the price value which is displayed using Sitefinity product list template changes successfully.

Please let me know how to change the price on currency change using MVC widget.

Regards,

Mateen

 

Posted by Community Admin on 18-Aug-2014 00:00
Hi Mateen,

You can use the eCommerce helpers in order to convert a price to another currency and format it:
var priceUk = EcommerceCurrencyFormatter.ToCurrencyString(50, "en", "GBP");
var priceEu = EcommerceCurrencyFormatter.ToCurrencyString(50, "de", "EUR");
var priceUsa = EcommerceCurrencyFormatter.ToCurrencyString(50, "en", "USD");
 
EcommerceExchangeRateConverter exchangeRateUtilities = new EcommerceExchangeRateConverter();
var convPriceUk = exchangeRateUtilities.ConvertPrice(50, "GBP");
var convPriceEu = exchangeRateUtilities.ConvertPrice(50, "EUR");
var convPriceUsa = exchangeRateUtilities.ConvertPrice(50, "USD");
The price will be converted to the currency using the defined exchange rate or service in the application.

Regards,
Nikola Zagorchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 
Posted by Community Admin on 19-Aug-2014 00:00

Thanks Nikola,

Through this code price is getting converted successfully.

Can you please tell how to get current selected currency name through code to pass as a parameter to EcommerceExchangeRateConverter e.g "USD" or "EUR".

Thanks

Posted by Community Admin on 21-Aug-2014 00:00
Hi Mateen,

You can use the following code snippet to get all currencies. This way you can build your own dropdown currency selector, since I think this way will be easier to get the selected currency. Moreover, you can update the products price depending on the currency using ajax, since the default currency control makes a postback.

List<string> currencies = EcommerceSettings.Currencies.SupportedCurrencies.Values.Where(ca => ca.IsActive).Select(ca => ca.Name).ToList();

If you want to use the currency selector with MVC widget you might be interested to get the selected value on document ready using JavaScript:
$(".sfcurrenciesDropDownList option[selected]").val()


Regards,
Nikola Zagorchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 
Posted by Community Admin on 25-Aug-2014 00:00

Hi Nikola,

I am facing the same issue.

How can I get the selected currency of default currency selector in code instead of script?

By using your code I am able to fetch the active currencies but not the currently selected one.

Regards,

Chaitanya

Posted by Community Admin on 28-Aug-2014 00:00
Hi Chaitanya,

Actually, you can get the selected currency from the cookie that is set when the currency selector is set and the currency is changed. The cookie is 'selectedDisplayCurrency' and the value is the currency in format "GBP" or "EUR" for instance. You can try read the value from the cookie, if it is not set, use the default currency.

Regards,
Nikola Zagorchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 
Posted by Community Admin on 02-Sep-2014 00:00

Thanks Nikola 

It is working fine now :)

Posted by Community Admin on 02-Sep-2014 00:00
Hello Mateen,

I am glad the issue is resolved.

Regards,
Nikola Zagorchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 
Posted by Community Admin on 06-Dec-2017 00:00

Okay so you can get the current currency from the cookie and I assume you can set the cookie value, but how do you actually change the selected currency in C#? 

This thread is closed