0

I have a shop with two Websites 1)US 2)Canada. The default currency is USD and the Canadian website is CAD.

The US website has a US shipping origin and the Canadian website has a Canadian shipping origin.

The issue is that Magento always passes the currency as USD (default currency) to the Fedex API when placing orders in the Admin. Even if the orders are for the Canadian website. The Fedex API rejects the call because the currency must match shipment origin currency.

I found that this function gets called in Mage_Usa_Model_Shipping_Carrier_Fedex to specify which currency to use

/**
 *  Return FeDex currency ISO code by Magento Base Currency Code
 *
 *  @return string 3-digit currency code
 */
public function getCurrencyCode ()
{
    $codes = array(
        'DOP' => 'RDD', // Dominican Peso
        'XCD' => 'ECD', // Caribbean Dollars
        'ARS' => 'ARN', // Argentina Peso
        'SGD' => 'SID', // Singapore Dollars
        'KRW' => 'WON', // South Korea Won
        'JMD' => 'JAD', // Jamaican Dollars
        'CHF' => 'SFR', // Swiss Francs
        'JPY' => 'JYE', // Japanese Yen
        'KWD' => 'KUD', // Kuwaiti Dinars
        'GBP' => 'UKL', // British Pounds
        'AED' => 'DHS', // UAE Dirhams
        'MXN' => 'NMP', // Mexican Pesos
        'UYU' => 'UYP', // Uruguay New Pesos
        'CLP' => 'CHP', // Chilean Pesos
        'TWD' => 'NTD', // New Taiwan Dollars
    );
    $currencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
    return isset($codes[$currencyCode]) ? $codes[$currencyCode] : $currencyCode;
}

As you would guess by looking at the code, it works on the frontend because the user's current store in under the correct website, but in the admin it always takes the default currency. I think the fix is the pull the currency off the store that is associated to the quote.

Am I missing something or is this a bug in Magento?

Thanks!

Chuck

1 Answer 1

0

I ended up extending the class Fedex class and getting the currency off of the shipping rate request rather than the active store:

public function getRequest() {
    return $this->_request;
}

public function getCurrencyCode ()
{
    $codes = array(
        'DOP' => 'RDD', // Dominican Peso
        'XCD' => 'ECD', // Caribbean Dollars
        'ARS' => 'ARN', // Argentina Peso
        'SGD' => 'SID', // Singapore Dollars
        'KRW' => 'WON', // South Korea Won
        'JMD' => 'JAD', // Jamaican Dollars
        'CHF' => 'SFR', // Swiss Francs
        'JPY' => 'JYE', // Japanese Yen
        'KWD' => 'KUD', // Kuwaiti Dinars
        'GBP' => 'UKL', // British Pounds
        'AED' => 'DHS', // UAE Dirhams
        'MXN' => 'NMP', // Mexican Pesos
        'UYU' => 'UYP', // Uruguay New Pesos
        'CLP' => 'CHP', // Chilean Pesos
        'TWD' => 'NTD', // New Taiwan Dollars
    );

    if($this->getRequest() && $this->getRequest()->getStore()) {
        $currencyCode = $this->getRequest()->getStore()->getBaseCurrencyCode();
    } else {
        $currencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
    }

    return isset($codes[$currencyCode]) ? $codes[$currencyCode] : $currencyCode;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.