1、Ecshop多货币 1:在themes下找到自己模板目录,进入library/page_header.lbi在自己喜欢的地方添加: 美元 英镑 欧元 人民币 澳元 自己修改,把RMB改成卢布,然后加上瑞士法郎SEK,加元CAD,代码是: USD GBP EUR RUB AU
3、D CAD SEK 2:在数据库里找到ecs_shop_config表,执行以下sql语句: INSERT INTO `ecs_shop_config` ( `id` , `parent_id` , `code` , `type` , `store_range` , `store_dir` , `value` , `sort_order` ) VALUES (
4、NULL , '1', 'rate', 'text', '', '', '1,0.71,0.69,6.85,1.45', '1' ), ( NULL , '1', 'ybprice_format', 'text', '', '', '£%s', '1' ),( NULL , '1', 'aprice_format', 'text', '', '', '€%s', '1' ),( NULL , '1', 'cprice_format', 'text', '', '', '¥%s', '1' ),( NULL , '1', 'aoprice_format', 'text', '',
5、 '', 'AU$%s', '1' ); 自己修改代码是: 3:在根目录下找到languages/zh_cn/admin/shop_config.php 增加代码: $_LANG['cfg_name']['rate'] = '货币汇率'; $_LANG['cfg_name']['ybprice_format'] = '英镑格式'; $_LANG['cfg_name']['aprice_format'] = '欧元格式'; $_LANG['cfg_name']['cprice_format'] = '人民币格式'; $_LANG['cfg_name']['aop
6、rice_format'] = '澳元格式'; $_LANG['cfg_desc']['rate'] = '输入规则按照和美元的汇率进行输入 US,EUR,BritishPound,China,Austrilian'; $_LANG['cfg_desc']['ybprice_format'] = '显示英镑格式,%s将被替换为相应的价格'; $_LANG['cfg_desc']['aprice_format'] = '显示欧元格式,%s将被替换为相应的价格'; $_LANG['cfg_desc']['cprice_format'] = '显示人民币格式,%s将被替换为相应的价格'
7、 $_LANG['cfg_desc']['aoprice_format'] = '显示澳元格式,%s将被替换为相应的价格'; 显示效果: 3:在根目录下得includes/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!=""){
8、 $_SESSION['currency']=$currency; } if ($_SESSION['currency']==''){ $_SESSION['currency']='USD'; } 4:在根目录下得includes/lib_common.php文件 927行下增加代码: $currency=$_SESSION['currency']; $rate=explode(',',$GLOBALS['_CFG']['rate']); if($currency=='USD'){ $price=$pri
9、ce*$rate[0]; } if($currency=='CNY'){ $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];
10、 } 982行增加代码: switch($currency) { case 'USD': return sprintf($GLOBALS['_CFG']['currency_format'], $price); break; case 'EUR': return sprintf($GLOBALS['_CFG']['aprice_format'], $price); break; case 'GBP':
11、 return sprintf($GLOBALS['_CFG']['ybprice_format'], $price); break; case 'AUD': return sprintf($GLOBALS['_CFG']['aoprice_format'], $price); break; case 'CNY': return sprintf($GLOBALS['_CFG']['cprice_forma
12、t'], $price); break; } //return sprintf($GLOBALS['_CFG']['currency_format'], $price); 5:支付方面: 在后台安装paypal支付方式。 6:打开数据库加入两个字段: ALTER TABLE `ecs_order_info` ADD `currency` VARCHAR( 10 ) NOT NULL , ADD `new_money` DECIMAL( 10, 2 ) NOT NULL 7:找到flow.php文件 找到1608行加入
13、代码: $order['currency']=$_SESSION['currency']; $order['new_money']=price_format_hs($order['order_amount']); 8:在根目录下得includes/lib_common.php文件增加方法 /** * 汇率转换后的金额 * * @access public * @param float $price 商品价格 * @return string */ function price_format_hs($price, $change_pri
14、ce = true) { $currency=$_SESSION['currency']; $rate=explode(',',$GLOBALS['_CFG']['rate']); if($currency=='USD'){ $price=$price*$rate[0]; } if($currency=='CNY'){ $price=$price*$rate[3]; } if($currency=='EUR'){ $price=$price*$r
15、ate[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']) {
16、 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) == '.')
17、 { $price = substr($price, 0, -1); } break; case 2: // 不四舍五入,保留1位 $price = substr(number_format($price, 2, '.', ''), 0, -1); break; case 3: // 直接取整 $price = i
18、ntval($price); break; case 4: // 四舍五入,保留 1 位 $price = number_format($price, 1, '.', ''); break; case 5: // 先四舍五入,不保留小数 $price = round($price); break; } } else {
19、 $price = number_format($price, 2, '.', ''); } return $price; } 9:找到admin/templates/order_list.hem 增加 货币,金额 两列: 找到admin/order.php 62行增加: $_SESSION['currency']='USD'; 5038行的sql语句增加两个字段:o.currency o.new_money 10:修改借口 找到includes/modules/payment/paypal.php 94行添加:$paypal_currency=$_SESSION["currency"]; 将$data_amount = $order['order_amount'];改为: $data_amount = $order['new_money']; 将$currency_code = $payment['paypal_currency'];改为 $currency_code = $payment['paypal_currency'];






