magento-1.7 - magento - 将订单金额从当前货币转换为基础货币

标签 magento-1.7

我正在尝试将订单金额从当前货币转换为基础货币,下面是我尝试过的代码,但没有成功。

$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); 
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode(); 
$price = 1; 

$priceTwo = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode); 

最佳答案

更新

试试这个代码,可能对你有帮助。对于这种情况,我使用总量。如果基础货币与当前货币不同,则会发生变化。

    $amount = $this->getOrder()->getGrandTotal();

    $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
    $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();

    if ($baseCurrencyCode != $currentCurrencyCode) {
        // convert price from current currency to base currency
        $amount = Mage::helper('directory')->currencyConvert($amount, $currentCurrencyCode, $baseCurrencyCode);

        // convert price from base currency to current currency
        //$priceTwo = Mage::helper('directory')->currencyConvert($amount, $baseCurrencyCode, $currentCurrencyCode);
    }

    $amountFinal = round($amount, 2);

关于magento-1.7 - magento - 将订单金额从当前货币转换为基础货币,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20852882/

相关文章:

mysql - 如何使用 SQL 在 magento 中获取产品 ID 和 sku

javascript - 一页结账在 Magento 版本中不起作用1.7.0.2

php - Magento - 扩展开发,处理卸载

php - 如何使用 magento 外部的 session 为客户登录创建 session

php - Magento 自定义模块 : multiple Image Uploader in adminhtml form

amazon-ec2 - 使多个实例上的 Varnish 缓存无效

magento-1.7 - Magento 通过商店 ID 获取管理 Controller 中的所有产品集合

email - 在 Magento 的自定义模块中发送订单确认邮件

Magento 导入客户数据并链接订单数据

magento-1.7 - Magento 层导航错误的产品计数