magento的多种货币

时间:2015-02-05 12:09:15

标签: php magento currency

我在magento有网站。我在其中设置了多种货币。一种是美元(默认),另一种是日元。使用这些步骤

在Magento设置多个货币商店: -

– Go to System –> Configuration –> Currency Setup

– Under ‘Currency Options‘, select Allowed currencies.

The selected currencies will be displayed in currency dropdown in category and product listing page. Remember that your Base currency and Default display currency selection should also be selected in Allowed currencies.

– Click ‘Save Config‘ button.

– Go to System –> Manage Currency Rates

– Select Import Service. By default it is ‘Webservicex’.

– Click ‘Import‘ button. This will update the currency rates values.

– Click ‘Save Currency Rates‘ button.

在产品列表页面,我会在左侧边栏的顶部看到货币选择下拉列表。但我想用日元和美元显示产品的多个价格。 请帮助。

2 个答案:

答案 0 :(得分:2)

在您希望显示产品多种产品价格的地方添加此代码。

<?php
    //remember the current currency
    $currentCurrency = Mage::app()->getStore()->getCurrentCurrencyCode();

    //remember the current currency object
    $currentCurrencyObject = Mage::app()->getStore()->getCurrentCurrency();

    //get allowed currencies
    $allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
    foreach ($allowedCurrencies as $currency) {
        //skip the current currency
        if ($currency != $currentCurrency) {
            //load the currency object
            $currObject = Mage::getModel('directory/currency')->load($currency);
            //change the store currency
            Mage::app()->getStore()->setCurrentCurrencyCode($currency);
            Mage::app()->getStore()->setCurrentCurrency($currObject);
            //show the price in the new currency
            echo $this->getPriceHtml($_product, true, '-clone-'.$currency);
        }
    }

    //reset the store currency
    Mage::app()->getStore()->setCurrentCurrencyCode($currentCurrency);
    Mage::app()->getStore()->setCurrentCurrency($currentCurrencyObject);
?>

enter image description here enter image description here

答案 1 :(得分:1)

您可以修改price.phtml并添加其他货币以显示

round( Mage::helper('directory')->currencyConvert( $amount, $_fromCurr, $_toCurr ), 2 )

您还必须更新Incl和excl税收计算。