Pages

Wednesday, July 3, 2013

Setting the Default Currency for a User in Magento

This won't alter the base price in the system but it will set the start price for a user. Simply add this to the top of /template/directory/currency.phtml

    $currentCurrency = $this->getCurrentCurrencyCode();

    if(!isset($currentCurrency)) $currentCurrency = 'NA';

    $currencies = array("GBP","USD","EUR");

    if(isset($_GET['cy']))
    {
    if (in_array(strtoupper($_GET['cy']),$currencies)) {
    if(strtoupper($_GET['cy']) != $currentCurrency)
    {
    header("Location: ".$this->helper('directory/url')->getSwitchCurrencyUrl()."currency/".$_GET['cy']);
    exit;
    }
    }
    }

Then, you can do something with the domains where a .co.uk site will redirect to the .com with ?cy=GBP at the end.

No comments:

Post a Comment