Currency Conversion in extension v3.0.3 and up

From v3.0.3 of the Magento 1 extension, Currency Conversion is included by default, if you are using Magento 1's standard conversion function.

Its added in my.clerk.io -> Designs, with the templateFormatter price_in_currency.

The helper can be added to your Design in the following way:

<div class="clerk-product-price">
   {{ price_in_currency price_final_excl_tax }}
</div> 

The helper will automatically convert the price to the currency of the current session, and add the currency symbol.

Example output:

Currency Conversion in earlier extensions

We have made many improvements in the later versions of our extension, so we highly recommend that you upgrade to the latest version, and get Currency Conversion this way.

Check this article to see how to upgrade from v1

Check this article to see how to upgrade from v2

If you want to keep your current version, but want to use Currency Conversion, read on.

  1. Start by finding this file in FTP:
    app->design->frontend->base->default->template->clerk->tracking.phtml
  2. Make a backup of the file!
  3. Replace the entire content of the file, with the below code
<?php
/** @var Clerk_Clerk_Block_Tracking $this */

$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
$currentCurrencySymbol = Mage::app()->getLocale()->currency($currentCurrencyCode)->getSymbol();
$rates = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, $currentCurrencyCode);
?>

<span class="clerk"  
  data-template="@exit-intent"
  data-exit-intent="true">
</span>

<script type="text/javascript">
    window.clerkAsyncInit = function() {
        Clerk.config({
            key: '<?php echo $this->getPublicKey(); ?>',
            collect_email: <?php echo $this->collectEmails() ? 'true' : 'false'; ?>,
            templateFormatters: {
                form_key: function () {
                    return '<?php echo $this->getFormKey(); ?>';
                },
                price_in_currency: function(price) {
                    price =  Math.round(price * 100) / 100;
                    var price_converted = Math.round((price * <?php echo (float)$rates[$currentCurrencyCode]; ?>) * 100) / 100;
                    var retVal = <?php echo json_encode($currentCurrencySymbol); ?> + ' ' + price_converted.toFixed(2).toString();

                    return retVal;
                }
            }
        });
    };
    (function(){
        var e = document.createElement('script'); e.type='text/javascript'; e.async = true;
        e.src = document.location.protocol + '//api.clerk.io/static/clerk.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
    })();
</script>


This will then allow you to use price_in_currencyin your Designs, as described in the beginning of the article.

Did this answer your question?