Solved

Allowing users to change currency on e-commerce web site

Posted on 2013-05-16
1
207 Views
Last Modified: 2013-08-22
I'm working on an e-commerce web site that currently displays all of the prices in USD.
I would like to add functionality that would allow the user to change the currency.

I was thinking about using a currency converter api to get the rates.
The base rate would be USD = 1

I would create a process that would consume the currency convert service/api and persist the rates every 12 hours.

On the top header of every page would be a menu to select a different currency.
Once the user selected a different currency, I would do a post back and look up the rate to calculate the prices.

I would then persist that selected rate to a cookie.

What are your thoughts? Any areas that can be improved on?
0
Comment
Question by:JRockFL
1 Comment
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
ID: 39210070
Use google api services to convert currency

And use one currency at back end and always show on front the currency change

like in calculations normally there is always one single currency

but on display you can just change currency by calling it from google api services

You just have to pass Currency from (etc PKR) , currency to (etc $)
Then it will give you the exact amount
So no need to worried about update your currency every day.
The code call the google api to convert currency

public static string ConvertCurrency (string To , string Amount , HttpRequest Request)
        {


        string Expression = Amount + “USD” + “=?” + To;
        string url = “http://www.google.com/ig/calculator?hl=en&q=” + Expression;


        string response = “”;
        string responseMsg = Request.Params.ToString();
        string post = responseMsg;
       
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        req.Method = “POST”;
        req.ContentType = “application/x-www-form-urlencoded”;
        req.ContentLength = post.Length;


        StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        writer.Write(post);
        writer.Close();


        StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream());
        response = reader.ReadToEnd();
        reader.Close();


        char[] cChar = new  char[3];
        string[] _params = new string[100];


        cChar[0] = ‘,’;
        _params = response.Split(cChar[0]);


        string ConvertedAmount = “”;


        ConvertedAmount = _params[1];
        ConvertedAmount = ConvertedAmount.Replace(“\”", “”);
        ConvertedAmount = ConvertedAmount.Replace(“rhs”, “”);
        ConvertedAmount = ConvertedAmount.Replace(“:”, “”);
        ConvertedAmount = ConvertedAmount.Trim();
        ConvertedAmount = ConvertedAmount.Remove(ConvertedAmount.IndexOf(‘ ‘), ConvertedAmount.Length – ConvertedAmount.IndexOf(‘ ‘));


        return ConvertedAmount;


        }

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now