我只是opencart的新手。我用它做了一个电子商务wesite。在该网站中,有多语言和多货币转换器选项的功能。现在我希望当用户点击他的语言时,它也应该将货币转换为他的语言。因此可以使用Opencart执行此操作。有人可以共享任何代码或任何参考链接,以便我可以这样做。任何帮助和建议都将非常值得一提。感谢。
答案 0 :(得分:1)
opencart管理面板中有一个货币选项,路径如下:
系统>本地化>货币
您可以更改并添加与特定语言相关的货币选项。
答案 1 :(得分: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;
}
答案 2 :(得分: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请求。