0
votes

I am trying to set up a website that allows about 6 different currencies. I originally was able to achieve this quite well using the currency exchange rates built into Magento and the customer could select which currency they prefered and all prices were displayed in that currency. However I recently discovered that despite the prices being in that currency Magento will still process the transactions in the base currency, in this case GBP. In fact it doesn't tell the customer this is what will happen until right at the end of the order which in my opinion is a very bad thing, some customers might also be charged more by their banks for the currency conversion.

As PayPal has been configured to allow payments in the 6 currencies I would like the customers to be able to pay in those currencies.

I have since found out that due to the way Magento has been built that this is no easy task and instead you should set up a new 'website' for each of the currencies, then I can set a base currency for each website. This sounds easy enough, however the tutorials about this all seem to force each website to have its own unique url - such as either us.website.com or website.com/us - but in this case that will not do and we need everything to use only the one base url website.com.

Does anyone know if this is possible?

I have been able to change the store by manually adding the following to index.php and I was thinking one possible solution would be to remember the users selection in the session and then load the correct store here. Would this be efficient or is there a better way to do this that I have overlooked?

/* Override store code */
if (isset($_GET['code']))
{
    $mageRunCode = $_GET['code'];
    $mageRunType = 'website';
}

Mage::run($mageRunCode, $mageRunType);

The website is running Magento Community Edition v1.7.0.2.

1

1 Answers

0
votes

I have been able to achieve this using something similar to the following in index.php

if (isset($_GET["currency"]) || !isset($_COOKIE["basewebsite"]))
{
        // List of available stores
        $stores = array('usd','aud','eur');
        $website = 'base'; // Default store ID

        if (isset($_GET['currency']) && in_array($_GET['currency'], $stores))
        {
             $website = $_GET['currency'];
        }

        // Set cookie to remember selection
        setcookie("basewebsite", $website);
        $_COOKIE['basewebsite'] = $website;
}
else
{
        $website = $_COOKIE['basewebsite'];
}

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : $website;

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';

Mage::run($mageRunCode, $mageRunType);

With this I can then change the website by simply adding ?currency=usd to the end of any Magento url. The selection is then remembered by the cookie and the correct website is loaded with any further requests.

This question hasn't received many views but if anyone does spot a better solution then please do let me know!