PDA

View Full Version : Currency changer throughout site?


teiuq1
12-29-2006, 11:14 AM
I'm currently setting up a T-shirt site. I'd like to know if there is some way I can make the currency change throughout the site at the click of a button.

I'd like perhaps to have a series of flags at the top of the page as a drop down menu. Once, say, the British flag is selected then all the prices on the site change to £, and once the American flag is selected they change to $USD.

Does anyone know if there's any easy way of doing this?

Thanks.

ess
12-29-2006, 12:13 PM
Hello there

Well, there is more than one way to do this.

Here is one way that I have used in the past, and seems to work just fine for me.

Basically, you program your website around URLS. that is, say that the main audience of the website come from the United Kingdom.

Therefore, you should ensure that the default locale is UK and your pages should look something like the following
http://your_site.com/
http://your_site.com/about/
http://your_site.com/products/

Now, once a user clicks on the US flag in order to change the locale, the pages should look something like the following
http://your_site.com/us/
http://your_site.com/us/about/
http://your_site.com/us/products/

Note the /us/ part in the URL. /us/ part indicates that the locale is for United States in this case...and as such, you should ensure that all calculations are made for US consumers and currency is US Dollars.

You can achieve the same thing for French consumers. for example,
http://your_site.com/fr/
http://your_site.com/fr/about/
http://your_site.com/fr/products/

Again, note the /fr/ part of the url. in this case it indicates that the consumer is French.

Another option is to use Cookies. However, the limitations of using cookies is that a user can easily disable cookies and as such, this method would not work.

Good luck.
Ess

ArcticFox
01-01-2007, 07:30 AM
Isn't there also a PHP way of doing this? PHP sessions, if I remember...

ess
01-01-2007, 12:51 PM
Of course you can use Sessions...

However, if you do use sessions, and a user bookmarks a given URL on the website (say for a given product) and they wish to go back to it one day...they wouldn't be able to view the product in the language they have selected whilst the session was active.

Therefore, Sessions are not a good solution in my opinion.

Good Luck.
ess

ArcticFox
01-01-2007, 10:52 PM
How about a script that detects the geographical location of the visitor which would automatically change displayed/submitted currency type?

teiuq1: Are you just wanting the currency to change, or are you also thinking of changing the language displayed?

ess
01-02-2007, 02:30 AM
Yeah...that is a good suggestion there. Though, that might slow the site a bit (external process that must be processed by the server)...as you would have to check user's geographical location with every request.

You can also use browser locales to establish user's default settings. This is much faster as this information will be sent with every request to the server...and as such...requires minimal processing by the server.

Pennimus
01-02-2007, 11:18 AM
I would recommend the automatic detection method in addition to a user chosen currency (so they can correct it if the script gets it wrong). Both would probably set a cookie which would seem to be the logical and most often used way of storing that type of information.

I'm sorry ess but using directory structure to handle this is somewhat clunky and terrible for search engine optimisation.

If there are to be foreign language versions these should be located at local .tlds for various reasons.

ess
01-02-2007, 01:10 PM
Hello there Pennimus,

I am not suggesting the use of Directory Structure at all.

Basically, my suggestion will provide a clean way for users to remember URLs in the website.

You can achieve the above suggestion by using .htaccess if you are programming in PHP, or by apply url patterns if you are programming in JSP.

Here is a simple example of how you can achieve this using .htaccess

ReWriteEngine On
ReWriteBase /

# Catch All UK Pages
ReWriteRule ^([a-z0-9_]+)/?$ index.php?page=$1&lang=gb [NC,L]

# Catch All French Pages
ReWriteRule ^fr/?$ index.php?page=main&lang=fr [NC,L]
ReWriteRule ^fr/([a-z0-9_]+)/?$ index.php?page=$1&lang=fr [NC,L]

As for search engine indexing...well, guess what...you can make sure that your website is indexed for each language by specifying the following in your header tag...with the first focusing in French version of the website.

<link rel="start" href="http://www.domain1.com/fr/" />

and for the UK pages...you can specify the following.

<link rel="start" href="http://www.domain1.com/" />

and for the US,
<link rel="start" href="http://www.domain1.com/us/" />

By programming the website this way, you will be sure that it is faster...and that you are not relying on cookies which can be disabled
by the user at any given instance. plus, a user can easily remember urls without having to bookmark them.

In any case, it is a matter of preference, and personally, I like to reduce reliance on cookies, JavaScript, etc...because users can choose to disable them.

Good Luck.
Ess

Pennimus
01-02-2007, 01:56 PM
I am not suggesting the use of Directory Structure at all.

You suggested building a dedicated "us" directory and an "fr" directory simply for changing the currency. That's a directory structure solution if ever I saw one.

If you mod rewrite this to a query string containing the information then the situation is even worse: you end up with the same problem from an SEO point of view (multiple versions of the same content indexed under different URLs leading to duplicate content issues and dispersion of credibility) but also make your URL's ugly for users.

Yes I'm aware that people can disable cookies but in my experience very few people actually do. Certainly not enough to offset the disadvantages of tracking this sort of info in the URL (since even the implications of cookies actually being blocked aren't that bad... if they are, a session could be started instead which would at least track the currency for the duration of the visit).

ArcticFox
01-02-2007, 10:45 PM
Found this site:
http://coinmill.com/webmaster_options.html

Might be possible to hack the codes to make it work as you need it. :)


Question: does everyone here know what this symbol is?: ¤ If we were to have multiple currencies, would we use that, or something else? Do our visitors know about that symbol and its meaning?

zoinbergs
03-03-2008, 09:47 PM
Hey guys! I thought I'd dig up this old thread if it's okay with you.

First off, although I'm relative new to JavaScript, let me just say that I'm really starting to love this stuff! I just recently tackled CSS, and am quite thrilled to venture down yet another path of code. My dad wrote code for 19 years actually.. so I think I have his genes, because this stuff is downright fun!

Anyways, I was wondering if someone could help me with a similar project (that I figured could continue in this thread because of how similar it is).

Here's what I'm trying to do..

I figured out how to turn a visitor's automatically detected country name, two-letter country iso code, and three-letter currency code into variables via this script..


<script type="text/javascript" src="http://gd.geobytes.com/gd?&variables=GeobytesCountry,GeobytesIso2,GeobytesCurrencyCode"></script>


..and I'm trying to have my site automatically update a PayPal purchase form so that everything is quoted in each user's currency.

Right now I'm working in USD, and everything is automatically converted upon checkout.. which I heavily stress to my potential customer base. I just wanted to see if I could take it one step further and quote my prices in their actual currency, as well as use it during checkout.

There are two problems that I face:

(1) For the life of me, I can't seem to figure out how to populate a hidden form's value with a simple variable (which I just know has gotta be only a line or two of code). I think I need to use something like document.getElementbyId but I'm not sure..

and

(2) I'd like to update the actual prices -- both in the form to be sent, as well as the one above each "add to cart" button. I've thought this through as best I can, and I believe I need to set up some sort of if/else statements to run through the currency codes and their respective prices (I only offer two products btw, so I only require two manually updated conversion tables -- no need to mess with exchange rates or anything).

I was thinking of doing something like..

if currency code is USD
then product1 price is $37 and product2 price is $17

else

if currency code is GBP
then product1 price is £19 and product2 price is £10

else

..(and so forth and so on)..


Okay, now the form I need to insert three different values (underscores) into is this:


<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="images/cart/atc0.png" name="submit" alt="Click here to add this item to your cart!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="johndoe@mail.com">
<input type="hidden" name="item_name" value="Product #1">
<input type="hidden" name="amount" value="____">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="cn" value="Note/Instructions">
<input type="hidden" name="currency_code" value="______">
<input type="hidden" name="lc" value="____">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</form>



..and so you know, lc means "locale" -- which is just the two-letter iso-3166 format for a country.

- - - - - - - -

Now my initial goal was to build a drop-down menu discussed earlier in this thread that could change these three values via javascript, and maybe that's still possible.. although if I can settle for a completely automatic process in the mean time, I'll put up with it. Obviously it does no good to people who, say, live on the border of two countries and their ISP is French when they live in Spain, but so far my StatCounter information has never been wrong, when comparing ip data against actual sales.

Perhaps with the introduction of GeoBytes data it wouldn't be too much trouble to build the actual drop down menu.. but then again, I could be wrong. Like I said, I'm very new to this stuff, and am trying my hardest to not ask for help! I've been doing great with Google searches and what not, but I admit I'm stumped on the price updating thing..

Anyways! Lemme shut up to keep this post concise. In my next post I'll go more into detail about a few things regarding country lists, PayPal, etc.

For now it would awesome if someone could give me a nudge in the right direction on how to populate hidden form values. The variables I have to work with are pretty basic, and return just fine when called via:


document.write(sGeobytesCountry+","+sGeobytesIso2+","+sGeobytesCurrencyCode);


I just don't know where to go from there, that's all.

Well thank you for reading this lengthy post, and I look forward to learning a thing or two from you today! Hopefuly someday I can be in your position, so that I can return the favor. ;)

Sincerely,
William

PS- If someone could move this thread into "JavaScript Programming" -- it might fit more appropriately there, since this is covered under JavaScript, right?

zoinbergs
03-03-2008, 10:09 PM
How about a script that detects the geographical location of the visitor which would automatically change displayed/submitted currency type?

I forgot to mention, this is exactly what I'm trying to do. I have the detection part down! :thumbsup: Now for the automatic changing..

Hmm, and maybe if a currency isn't supported, the script would default to another currency.

It wouldn't be hard for this script to refer to an exchange rate table, would it? I'm guessing that if it's manually updated, that'd be fine. Otherwise some sort of Ajax would have to be implemented, no?

udjamaflip
03-05-2008, 03:57 PM
How about a script that detects the geographical location of the visitor which would automatically change displayed/submitted currency type?

teiuq1: Are you just wanting the currency to change, or are you also thinking of changing the language displayed?

I would advise strongly against this, and default to english. I lived abroad (Spain) and it did annoy me that it assumed I was Spanish, dont get me wrong - i'm not ignorant and CAN speak spanish. But it wasnt nice when i first moved to try and navigate to where the languages was (ryanair is a *** for this)

Remember #1 business language of the world is English, and most commonly known as well (if you take into consideration of 2nd/3rd/4th languages etc..)

zoinbergs
03-05-2008, 05:13 PM
I would advise strongly against this, and default to english. I lived abroad (Spain) and it did annoy me that it assumed I was Spanish, dont get me wrong - i'm not ignorant and CAN speak spanish. But it wasnt nice when i first moved to try and navigate to where the languages was (ryanair is a *** for this)

Remember #1 business language of the world is English, and most commonly known as well (if you take into consideration of 2nd/3rd/4th languages etc..)

Yep, I agree. I'm keeping my site language in English just for that reason.

Now you wouldn't be quite as annoyed though, if just currencies were quoted in your nation's most commonly used currency.. would you?

The question is, which is more favorable: seeing USD first (because it's so popular in the online business world) and doing a quick mental calculation to convert it to EUR (for example), or just simply seeing EUR in the first place?

I'm just trying to boost customer confidence that I do business in their currency, and ship to their country. :)