0

我只是opencart的新手。我用它做了一个电子商务网站。在该网站中,具有多语言和多货币转换器选项的功能。现在我希望当用户点击他的语言时,它也应该将货币转换为他的语言。那么是否可以使用Opencart来做到这一点。有人可以分享任何代码或任何参考链接,以便我可以做到这一点。任何帮助和建议都将不胜感激。谢谢。

4

3 回答 3

1

在 opencart 管理面板中有一个货币选项,路径是这样的:

系统 > 本地化 > 货币

在那里您可以更改和添加与特定语言相关的货币选项。

于 2012-11-12T12:40:40.267 回答
1
if ($currency && $this->has($currency)) {
            $symbol_left   = $this->currencies[$currency]['symbol_left'];
            $symbol_right  = $this->currencies[$currency]['symbol_right'];
            $decimal_place = $this->currencies[$currency]['decimal_place'];
        } else {
            if($_SESSION['language']=="es"):

                $symbol_right  = $this->currencies[$this->code]['symbol_right'];
                else:
    $from="USD";
    $to="MXN";
    $path = "http://www.google.com/ig/calculator?hl=en&q=1".$from."=?".$to;
    $rawdata = file_get_contents($path);
    $data = explode('"', $rawdata);
    $data = explode(' ', $data['3']);
    $var = $data['0'];
    $e=round($var,3);
    if ($e):
        $number=$number / $e;
    else:
        $default_dollar=12.863;
        $number=$number / $default_dollar;                    
    endif;    
        $symbol_right=" USD";
    endif;
            $symbol_left   = $this->currencies[$this->code]['symbol_left'];

            $decimal_place = $this->currencies[$this->code]['decimal_place'];

            $currency = $this->code;
        }
于 2012-11-13T18:10:39.340 回答
0

在 :\system\library\currency.php 中有一个函数

    public function format($number, $currency = '', $value = '', $format = true) {
    if ($currency && $this->has($currency)) {
        $symbol_left   = $this->currencies[$currency]['symbol_left'];

        $symbol_right  = $this->currencies[$currency]['symbol_right'];
        $decimal_place = $this->currencies[$currency]['decimal_place'];
    } else {            
        $symbol_left   = $this->currencies[$this->code]['symbol_left'];
        $symbol_right  = $this->currencies[$this->code]['symbol_right'];
        $decimal_place = $this->currencies[$this->code]['decimal_place'];           
        $currency = $this->code;
    }

如果您仔细查看,您可以在此处根据语言更改货币,或者您可以使用 jquery 发送 ajax 请求以更改货币。

于 2012-11-12T13:05:50.660 回答