美元   ,咨信网zixin.com.cn" />
收藏 分销(赏)

Ecshop多货币解方案的开发.doc

上传人:仙人****88 文档编号:11258458 上传时间:2025-07-11 格式:DOC 页数:9 大小:468KB 下载积分:10 金币
下载 相关 举报
Ecshop多货币解方案的开发.doc_第1页
第1页 / 共9页
Ecshop多货币解方案的开发.doc_第2页
第2页 / 共9页


点击查看更多>>
资源描述
Ecshop多货币 1:在themes下找到自己模板目录,进入library/page_header.lbi在自己喜欢的地方添加: <a href="{$url_head}&currency=USD">美元</a> &nbsp; <a href="{$url_head}&currency=GBP">英镑</a> &nbsp; <a href="{$url_head}&currency=EUR">欧元</a> &nbsp; <a href="{$url_head}&currency=CNY">人民币</a> &nbsp; <a href="{$url_head}&currency=AUD">澳元</a> 自己修改,把RMB改成卢布,然后加上瑞士法郎SEK,加元CAD,代码是: <a href="index.php?currency=USD">USD</a> &nbsp; <a href="index.php?currency=GBP">GBP</a> &nbsp; <a href="index.php?currency=EUR">EUR</a> &nbsp; <a href="index.php?currency=RUB">RUB</a> &nbsp; <a href="index.php?currency=AUD">AUD</a> &nbsp; <a href="index.php?currency=CAD">CAD</a> &nbsp; <a href="index.php?currency=SEK">SEK</a> 2:在数据库里找到ecs_shop_config表,执行以下sql语句: INSERT INTO `ecs_shop_config` ( `id` , `parent_id` , `code` , `type` , `store_range` , `store_dir` , `value` , `sort_order` ) VALUES ( 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', '', '', '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']['aoprice_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将被替换为相应的价格'; $_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!=""){ $_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=$price*$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]; } 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': 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_format'], $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行加入代码: $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_price = 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*$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, '.', ''); } 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'];
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服