Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Currency flags instead of dropdown sidebox

Currency flags instead of dropdown sidebox

Views: 1,951

Results 1 to 5 of 5
10 Jan 2012, 8:27 PM
#1
mighty_midget avatar

mighty_midget

New Zenner

Join Date:
Sep 2011
Location:
UK
Posts:
72
Plugin Contributions:
0

Currency flags instead of dropdown sidebox

Hi,

Im looking to add currency flags to my website instead of a dropdown sidebox. I have read a few of the suggestions already but not sure how to go about it as there are a couple of ways of doing it from what ive read. Please Help.

Thanks

11 Jan 2012, 10:50 PM
#2
nao_1 avatar

nao_1

New Zenner

Join Date:
Jan 2012
Location:
London, UK
Posts:
5
Plugin Contributions:
0

Re: Currency flags instead of dropdown sidebox

An easy way to do this would be mimic the functionality of the form for the currency sidebox (the drop-down menu).

Below is the code for the form on version 1.3.9h as it exists on my local computer.

<form name="currencies_form" action="http://127.0.0.1/zc/index.php?main_page=index" method="get"><select name="currency" onchange="this.form.submit();">
  <option value="USD">US Dollar</option>
  <option value="EUR">Euro</option>
  <option value="GBP" selected="selected">GB Pound</option>
  <option value="CAD">Canadian Dollar</option>
  <option value="AUD">Australian Dollar</option>
</select>
<input type="hidden" name="main_page" value="index"></form>

The form uses the GET method to send form data to the server. This is convenient because it shows us the information we need to create links that change the currency setting.

At any rate, here are the links you'd end-up with.

USD / American Flag
http://127.0.0.1/zc/index.php?main_page=index&currency=USD

GBP / British Flag
http://127.0.0.1/zc/index.php?main_page=index&currency=GBP

EUR / EURO sign or list 17 flags!
http://127.0.0.1/zc/index.php?main_page=index&currency=EUR

NB Be sure to insert your own IP/domain name and directory path in place of mine (my IP/domain is '127.0.0.1' and my directory path is 'zc'. Change those to suit your instance of Zen Cart.)

For other currencies, just substitute a the 3 letter currency code for whatever currencies you want to offer. You must make sure the currency codes are defined in the Admin console before you can use them, Admin->Localization->Currencies

The full HTML code, that is, a hyper-link'ed flag image that changes to currency setting, would look something like this:

<a href="http://127.0.0.1/zc/index.php?main_page=index&currency=EUR><img src="EuroFlag.png" width="30" height="20"></a>

Now you just need to figure out where to put the currency flag links on your template and hard-code the links into the PHP. Personally, I'm not a big fan of hard-coding anything into ZC that cannot be changed via the admin console, but then, I'm also a fan of getting a reasonable amount of sleep!

Hope this helps.

Best wishes,

Nao

12 Jan 2012, 3:02 PM
#3
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Currency flags instead of dropdown sidebox

I used this mod: Language/Currency Links in Header

then I added an ID to each currency link:

$content .= '<a id="navTopCurrencyId' . $currencies_array[$i]['id'] . '"' . 'href="'

This way you can add/delete currencies from admin as you normally would

All you have to do is add the currency flag as a background via css:

#navTopCurrencyIdUSD {
padding:7px 2px 7px 30px;
background-image: url(../images/USD.png);
background-repeat:no-repeat;
}

You can see it in action here

12 Jan 2012, 6:25 PM
#4
nao_1 avatar

nao_1

New Zenner

Join Date:
Jan 2012
Location:
London, UK
Posts:
5
Plugin Contributions:
0

Re: Currency flags instead of dropdown sidebox

I would definitely take your approach rbarbour. Fewer calls to the server and fully controlled via admin panel = excellent stuff!

13 Jan 2012, 2:28 PM
#5
mighty_midget avatar

mighty_midget

New Zenner

Join Date:
Sep 2011
Location:
UK
Posts:
72
Plugin Contributions:
0

Re: Currency flags instead of dropdown sidebox

Thanks for the replies guys.

They both sound great. Dont want the flags in my header though. Would much rather have them in a sidebox but not as the dropdown menu. Just as link icons that change with one click of a mouse.