gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 07:38:58 25 4
gpt4 key购买 nike

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

$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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com