Announcement

Collapse
No announcement yet.

Currency conversion javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Currency conversion javascript

    Hi all

    Can any javascript gurus out there offer some help with the following please?

    We are trying to display the dollar and euro price of the shopping cart total (which is in GBP) on the shopping cart page.

    But it doesn't work. The position on the page where the dollar and euro amounts should appear is blank.

    Here is how we are trying to do it:

    In Act_ShoppingCartXML.html we have placed the following:

    <script language=JavaScript>
    <!--
    var OrderTotal = 'NETQUOTEVAR:TOTAL';
    // -->
    </script>

    This enables the NQV:TOTAL to work in the next template (Act_ShoppingCart.html) which is where we intend to convert the cart total and display it, as a variable called 'OrderTotal'.

    Then in Act_ShoppingCart.html we have placed the following two bits of code where we want the dollar and euro prices to appear.

    <script language=JavaScript>
    <!--
    Dollars("OrderTotal");
    // -->
    </script>

    <script language=JavaScript>
    <!--
    Euros("OrderTotal");
    // -->
    </script>

    In the Primary template we have added a couple of lines to include two javascript files:

    <SCRIPT LANGUAGE="JavaScript" SRC="exchange_rates.js" TYPE="text/javascript"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="currency.js" TYPE="text/javascript"></SCRIPT>

    The first JS file contains two lines to define the exchange rates to be used:

    var dollarrate = 1.4;
    var eurorate = 0.86;

    The second JS file is what does all the work and I think that the problem is in this file.

    I have attached currency.js to this thread as a txt file.

    My knowledge of javscript is rather lacking and I'm unable to work out why it does not work. Can anyone out there offer any advice?

    Thanks

    Nick
    Attached Files
    Hazelnet Web Solutions
    www.hazelnet.co.uk
    Actinic & Worldpay Partners
    Specialising in ecommerce and
    online promotion.

    Workwear and Promotional Clothing
    www.workwearhouse.co.uk
    Logo Your Polo!

    #2
    I'm no expert at JavaScript but here are a few things to check.

    1) Try putting the function in Act_ShoppingCartXML.html' rather than 'Act_ShoppingCart.html' in order to eliminate one possible cause of the problem (i.e. the incorrect setting of the 'OrderTotal' variable).

    2) View the source of the 'view cart' page to ensure the lines about
    <SCRIPT LANGUAGE="JavaScript" SRC="exchange_rates.js" TYPE="text/javascript"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="currency.js" TYPE="text/javascript"></SCRIPT>
    are present and correct.

    3) Just try and get it working in a non-Actinic HTML page - to check the basic functionality works.

    Comment

    Working...
    X