2012-11-11 96 views
0

我只是opencart的新手。我用它做了一個電子商務網站。在該網站上有多語種多功能貨幣轉換器選項。現在我希望當用戶點擊他的語言時,它也應該將貨幣轉換爲他的語言。那麼可以用Opencart來做到這一點。有人可以分享任何代碼或任何參考鏈接,以便我可以做到這一點。任何幫助和建議都將非常可觀。謝謝。Opencart更改語言與貨幣更改選項

回答

1

有一個在Opencart的管理面板的貨幣選擇,路徑是這樣的:

系統>本地化>貨幣

那裏你可以改變,並添加相關的特定語言的貨幣期權。

+0

感謝您的回覆,但我想同時轉換語言和貨幣。這隻會改變語言。 – NewUser

+0

OpenCart僅使用ISO格式貨幣 –

0

有一個函數在:\ SYSTEM \庫\ 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請求貨幣變化。

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; 
     }