《Ecshop多货币解方案设计地开发.doc》由会员分享,可在线阅读,更多相关《Ecshop多货币解方案设计地开发.doc(9页珍藏版)》请在课桌文档上搜索。
1、wordEcshop多货币1:在themes下找到自己模板目录,进入library/page_header.lbi在自己喜欢的地方添加:美元 英镑 欧元 人民币 澳元自己修改,把RMB改成卢布,然后加上瑞士法郎SEK,加元CAD,代码是:USD GBP EUR RUB AUD CAD SEK2:在数据库里找到ecs_shop_config表,执行以下sql语句:INSERT INTO ecs_shop_config (id ,parent_id ,code ,ty
2、pe ,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、LANGcfg_namerate = 货币汇率;$_LANGcfg_nameybprice_format = 英镑格式;$_LANGcfg_nameaprice_format = 欧元格式;$_LANGcfg_namecprice_format = 人民币格式;$_LANGcfg_nameaoprice_format = 澳元格式;$_LANGcfg_descrate = 输入规如此按照和美元的汇率进展输入US,EUR,BritishPound,China,Austrilian;$_LANGcfg_descybprice_format = 显示英镑格式,%s将被替换为相应的价格;$_LANGc
4、fg_descaprice_format = 显示欧元格式,%s将被替换为相应的价格;$_LANGcfg_desccprice_format = 显示人民币格式,%s将被替换为相应的价格;$_LANGcfg_descaoprice_format = 显示澳元格式,%s将被替换为相应的价格;显示效果:增加以下代码:参考$url_this=:/.$_SERVER_HOST.$_SERVERPHP_SELF.?id=.$_GETid;$smarty-assign(url_head,$url_this);$currency=$_GETcurrency;if ($currency!=) $_SESSIO
5、Ncurrency=$currency;if ($_SESSIONcurrency=) $_SESSIONcurrency=USD;927行下增加代码: $currency=$_SESSIONcurrency; $rate=explode(,$GLOBALS_CFGrate); if($currency=USD) $price=$price*$rate0; if($currency=Y) $price=$price*$rate3; if($currency=EUR) $price=$price*$rate1; if($currency=GBP) $price=$price*$rate2; if
6、($currency=AUD) $price=$price*$rate4; 982行增加代码:switch($currency) case USD: return sprintf($GLOBALS_CFGcurrency_format, $price); break; case EUR: return sprintf($GLOBALS_CFGaprice_format, $price); break; case GBP: return sprintf($GLOBALS_CFGybprice_format, $price); break; case AUD: return sprintf($GL
7、OBALS_CFGaoprice_format, $price); break; case Y: return sprintf($GLOBALS_CFGcprice_format, $price); break; /return sprintf($GLOBALS_CFGcurrency_format, $price);5:支付方面:在后台安装paypal支付方式。6:打开数据库参加两个字段:ALTER TABLE ecs_order_info ADD currency VARCHAR( 10 ) NOT NULL ,ADD new_money DECIMAL( 10, 2 ) NOT NULL
8、找到1608行参加代码: $ordercurrency=$_SESSIONcurrency;$ordernew_money=price_format_hs($orderorder_amount);/* * 汇率转换后的金额 * * access public * param float $price 商品价格 * return string */function price_format_hs($price, $change_price = true) $currency=$_SESSIONcurrency; $rate=explode(,$GLOBALS_CFGrate); if($curr
9、ency=USD) $price=$price*$rate0; if($currency=Y) $price=$price*$rate3; if($currency=EUR) $price=$price*$rate1; if($currency=GBP) $price=$price*$rate2; if($currency=AUD) $price=$price*$rate4; if ($change_price & defined(ECS_ADMIN) = false) switch ($GLOBALS_CFGprice_format) case 0: $price = number_form
10、at($price, 2, ., ); break; case 1: / 保存不为 0 的尾数 $price = preg_replace(/(.*)(.)(0-9*?)0+$/, 123, 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 =
11、 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;增加 货币,金额 两列:62行增加:$_SESSIONcurrency=USD;10:修改借口94行添加:$paypal_currency=$_SESSIONcurrency; 将$data_amount = $orderorder_amount;改为:$data_amount = $ordernew_money;将$currency_code = $paymentpaypal_currency;改为$currency_code = $paymentpaypal_currency;9 / 9