Presetting US$ when entering the site.

Automatic multi currency display on entire catalog.

Run your catalog in a main currency (or a main and alternate) with the customer having the option to turn on an additional currency throughout the Catalog, Cart and Checkout.
Post Reply
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Presetting US$ when entering the site.

Post by norman »

The following code will allow another currency to be automatically selected when entering the site from any page. It is set to select US$. If you want another currency preset then change the line.

<INPUT TYPE="hidden" NAME="initialcurrency" VALUE="USD">

to contain the ISO code of the required currency.

Installation

Paste the code below into Act_Primary.html (and Act_BrochurePrimary.html) on a new line immediately after the <body .... > tag.

Code: Select all

<span style="display:none; visibility:hidden">
<FORM NAME="textor1"> 
<INPUT TYPE="hidden" NAME="texaccept" VALUE="site operator accepts conditions at http://cconv.textor.com">
<INPUT TYPE="hidden" NAME="basevalue" VALUE="1.00">
<INPUT TYPE="hidden" NAME="basecurrency" VALUE="CUSTOMVAR:MAINCURRENCY">
<INPUT TYPE="hidden" NAME="initialcurrency" VALUE="USD">
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://cconv.textor.com/conv1a.js"> </SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://cconv.textor.com/fixnetscape3bug1a.js"></SCRIPT>
</FORM>
</span>
<script type="text/javascript">
<!--  Extract and remember the US$ to UK£ rate
if ( document.cookie )							// only if cookies enabled
  {
  if ( document.cookie.indexOf('destcurr=') == -1 ) 			// cookie not set so lets set it
    {
    var baserate = -1;
    var intialrate = -1;
    var basecurrency = document.textor1.basecurrency.value;		// our normal currency
    var initialcurrency = document.textor1.initialcurrency.value;	// our additional currency
    for(var i=0; i <= 100 ;i++)						// all the ISO codes						
      {
      if ( iso[i] == basecurrency ) baserate = curate[i];		// look for the BASE to $ rate
      if ( iso[i] == initialcurrency ) intialrate = curate[i];		// look for the DEST to $ rate
      }
    if ( (baserate > -1) && (intialrate > -1) )				// valid rate
      {
      document.cookie = 'destcurr=' + escape(initialcurrency + ':' + baserate + ':' + intialrate) + '; path=/';	// set the cookie
      document.location.reload();					// and reload the page
      }
    }
  }
//-->
</script>
Note that this will cause the page to reload automatically (just like when you choose another currency from the popup). So the first time a customer goes to your site the first page they view will load twice. Once with no alternate currency, then again to display the page with alternate currencies.

If you only have customers entering the site from a page that doesn't contain prices then you can avoid this double load by changing the line

document.location.reload(); // and reload the page

to be

// document.location.reload(); // and reload the page
Norman
Post Reply