首先修改数据库,找到ecs_shop_config这个表,在里面添加如图所示的几条信息
之后,找到\languages\zh_cn\admin\shop_config.php这个文件,在适当位置添加
$_LANG['cfg_name']['rate'] = '货币汇率'; $_LANG['cfg_desc']['rate'] = '输入规则按照和美元的汇率进行输入: 英镑,欧元,美元,人民币,日元,港元,澳元。'; $_LANG['cfg_name']['ybprice_format'] = '英镑格式'; $_LANG['cfg_name']['oyprice_format'] = '欧元格式'; $_LANG['cfg_name']['myprice_format'] = '美元格式'; $_LANG['cfg_name']['rmbprice_format'] = '人民币格式'; $_LANG['cfg_name']['ryprice_format'] = '日元格式'; $_LANG['cfg_name']['gyprice_format'] = '港元格式'; $_LANG['cfg_name']['ayprice_format'] = '澳元格式'; $_LANG['cfg_desc']['ybprice_format'] = '显示英镑格式,%s将被替换为相应价格'; $_LANG['cfg_desc']['oyprice_format'] = '显示欧元格式,%s将被替换为相应价格'; $_LANG['cfg_desc']['myprice_format'] = '显示美元格式,%s将被替换为相应价格'; $_LANG['cfg_desc']['rmbprice_format'] = '显示人民币格式,%s将被替换为相应价格'; $_LANG['cfg_desc']['ryprice_format'] = '显示日元格式,%s将被替换为相应价格'; $_LANG['cfg_desc']['gyprice_format'] = '显示港元格式,%s将被替换为相应价格'; $_LANG['cfg_desc']['ayprice_format'] = '显示澳元格式,%s将被替换为相应价格';
然后在后台管理界面的商店设置的下面就会出现相应的设置选项,设置好保存。
下来找到include\init.php这个文件,在其末尾加入
$url_this = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']."?id=".$_GET['id']; $smarty->assign("url_head",$url_this); $currency = @$_GET['currency']; if($currency!=""){ $_SESSION['currency'] = $currency; } if($_SESSION['currency'] == '') { $_SESSION['currency'] = 'RMB'; } echo $_SESSION['currency'];
在找到\include\lib_common.php这个文件,将function price_format这个函数修改为
function price_format($price, $change_price = true) { $currency = $_SESSION['currency']; $rate = explode(',',$GLOBALS['_CFG']['rate']); if($currency == 'RMB') { $price = $price*$rate[0]; } if($currency == 'USD') { $price = $price*$rate[3]; } if($currency == 'EUR') { $price = $price*$rate[1]; } if($currency == 'GBP') { $price = $price*$rate[2]; } if($currency == 'AUD') { $price = $price*$rate[4]; } if ($change_price && defined('ECS_ADMIN') === false) { switch ($GLOBALS['_CFG']['price_format']) { case 0: $price = number_format($price, 2, '.', ''); break; case 1: // 保留不为 0 的尾数 $price = preg_replace('/(.*)(\\.)([0-9]*?)0+$/', '\1\2\3', number_format($price, 2, '.', '')); if (substr($price, -1) == '.') { $price = substr($price, 0, -1); } break; case 2: // 不四舍五入,保留1位 $price = substr(number_format($price, 2, '.', ''), 0, -1); break; case 3: // 直接取整 $price = intval($price); break; case 4: // 四舍五入,保留 1 位 $price = number_format($price, 1, '.', ''); break; case 5: // 先四舍五入,不保留小数 $price = round($price); break; } } else { $price = number_format($price, 2, '.', ''); } switch ($currency) { case 'RMB': return sprintf($GLOBALS['_CFG']['currency_format'], $price); break; case 'USD': return sprintf($GLOBALS['_CFG']['myprice_format'], $price); break; case 'EUR': return sprintf($GLOBALS['_CFG']['oyprice_format'], $price); break; case 'AUD': return sprintf($GLOBALS['_CFG']['ayprice_format'], $price); break; } }
找到\themes\default\library\page_header.lbi这个文件,在适当位置加入
<select name="hbxz" id="hbxz" onChange="changhb(this.value)"> <option>请选择币种</option> <option value="RMB" >人民币</option> <option value="USD" >USD</option> <option value="AUD" >AUG</option> <option value="EUR" >Euro</option> </select> <script> function changhb(kk) { location.href = "{$url_head}"+"¤cy=" + kk; } </script>
这样,在前台页面里就会显示出选择语言的选项。
但是这样做会发现每次都清除缓存才能显示出来,所以就得把根目录下面的所有php文件里带有
$smarty->caching = true;
这句话改为
$smarty->caching = false;
这样就使之不使用缓存技术,会立即改变。