NorPrice V2 - 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: 1238
Joined: Sat Feb 07, 2004 9:55 pm

NorPrice V2 - presetting US$ when entering the site.

Post by norman » Thu Jan 03, 2013 6:21 pm

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 your Overall Layout(s) on a new line immediately after the <body .... > tag.

Code: Select all

<div 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="<actinic:variable name="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>
</div>
<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