+ Reply to Thread
Results 1 to 9 of 9

Thread: Currency conversion

  1. #1
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    8,056
    Squirrelcart version
    v3.5.0

    Currency conversion

    One of our customers mentioned a free currency conversion utility that some of you may be interested in:
    http://dynamicconverter.com/

    I just tried it in Squirrelcart, and it works OK. You need to follow their instructions, and paste their code directly before the closing </body> tag in your storefront page (store.php by default).

    It doesn't seem to convert prices in drop down product option fields (select tags) by default. Their documentation indicates that to do so, you need to add an "id" attribute set to "convert". This is bad practice as id attributes must only be used once per page. I sent them an email to see if there is another way to handle that.

  2. #2
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    8,056
    Squirrelcart version
    v3.5.0
    We've done some more testing, and have it fully working. Here are the setup instructions for this:

    1. Copy the Javascript code for Dynamic Converter that they provide you to your clipboard

    2. In version 3.x:
    open the template file store_main.tpl.php (see this page for instructions on modifying template files).

    In version 2.x:
    Open your storefront page (store.php by default)

    3. Locate the closing body tag:
    Code:
    </body>
    4. Paste their Javascript directly befopre that closing body tag

    5. Save the file

    6. Open the template file option_select.tpl.php in an editor
    Important - See this page for instructions on modifying templates:
    http://squirrelcart.com/help/?Modify...Templates.html

    7. Locate the select tag, and find the class attribute:
    Code:
    class="<?=$Missing_BG_Class?>"
    Add a "dcconvert" class inside the quotes:
    Code:
    class="<?=$Missing_BG_Class?> dcconvert"
    8. Save the file

    If you aren't using the QuickTotal module, stop here.

    9. Open squirrelcart/modules/quick_total/quick_total.js.php in an editor

    10. Scroll to the very bottom of the file, and find this code:
    Code:
        // update item total on product page
        prodTotalTag.innerHTML = '<?php print $SC['settings']['Currency_Symbol']?>' + prodTotal;
        
    }
    
    </script>
    11. Before the closing brace } add this:
    Code:
        // call dynamic convertor
        if  (window.dc_convert_now) dc_convert_now();
    The bottom of that file should now look like this:

    Code:
        // update item total on product page
        prodTotalTag.innerHTML = '<?php print $SC['settings']['Currency_Symbol']?>' + prodTotal;
        
        // call dynamic convertor
        if  (window.dc_convert_now) dc_convert_now();
    }
    
    </script>
    12. Save the file

  3. #3
    Client
    Join Date
    Nov 2004
    Location
    England
    Posts
    230
    Squirrelcart version
    v2.6.1

    Thanks

    This is great Jamie. Thanks for letting us know about this. Works a treat!

  4. #4
    Client
    Join Date
    Nov 2008
    Posts
    27
    Squirrelcart version
    v3.4.2

    Nice!

    Excellent find, thanks Jamie.

  5. #5
    Client SketchWork's Avatar
    Join Date
    Aug 2007
    Posts
    79
    Squirrelcart version
    v3.3.2
    Hi Jamie,

    Does this still work in the current version of SquirrelCart or has the code changed too much?

    Many thanks,

    Justin

  6. #6
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    8,056
    Squirrelcart version
    v3.5.0
    Yes, the instructions above include instructions for version 3.x.

  7. #7
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    8,056
    Squirrelcart version
    v3.5.0
    I just added this for someone. The currency conversion script was not detecting the prices because we wrap the currency prefix and suffix in span tags so you could target them via CSS. If you have trouble getting this script to work, try changing the content of the price_html.tpl.php template file from this:
    PHP Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__?> -->

    <span class="sc_amount">
        <?php if (SC_CURRENCY_PREFIX): ?>
            <span class="currency_prefix"><?php print SC_CURRENCY_PREFIX ?></span>
        <?php endif; ?>
        <?php print $Amount ?>
        <?php if (SC_CURRENCY_SUFFIX): ?>
            <span class="currency_suffix"><?php print SC_CURRENCY_SUFFIX ?></span>
        <?php endif; ?>
    </span>

    to this:
    PHP Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__?> -->

    <span class="sc_amount">
        <?php if (SC_CURRENCY_PREFIX): ?><?php print SC_CURRENCY_PREFIX ?><?php endif; ?><?php print $Amount ?><?php if (SC_CURRENCY_SUFFIX): ?> <?php print SC_CURRENCY_SUFFIX ?><?php endif; ?>
    </span>

  8. #8
    Client
    Join Date
    Feb 2007
    Location
    Penarth, Wales
    Posts
    27
    Squirrelcart version
    v3.3.5
    The code I have for the file "option_select.tpl.php" is different from the above (I'm using 3.4.1).
    Jamie, would you clarify the changes please.

  9. #9
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    8,056
    Squirrelcart version
    v3.5.0
    I updated that step above.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts