+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / Currencydropdoenlist - DisplayPrice in MVC doesn't chnage

Currencydropdoenlist - DisplayPrice in MVC doesn't chnage

8 posts, 0 answered
  1. Mateen
    Mateen avatar
    13 posts
    Registered:
    29 Aug 2012
    14 Aug 2014
    Link to this post

    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

     

  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    08 Dec 2016
    18 Aug 2014
    Link to this post
    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
     
  3. Mateen
    Mateen avatar
    13 posts
    Registered:
    29 Aug 2012
    19 Aug 2014 in reply to Nikola Zagorchev
    Link to this post

    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

  4. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    08 Dec 2016
    21 Aug 2014
    Link to this post
    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
     
  5. Chaitanya
    Chaitanya avatar
    22 posts
    Registered:
    14 Oct 2013
    25 Aug 2014 in reply to Nikola Zagorchev
    Link to this post

    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

  6. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    08 Dec 2016
    28 Aug 2014
    Link to this post
    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
     
  7. Mateen
    Mateen avatar
    13 posts
    Registered:
    29 Aug 2012
    02 Sep 2014
    Link to this post

    Thanks Nikola 

    It is working fine now :)

  8. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    08 Dec 2016
    02 Sep 2014
    Link to this post
    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
     
8 posts, 0 answered