Ecshop多货币解方案设计地开发.doc
wordEcshop多货币1:在themes下找到自己模板目录,进入library/page_header.lbi在自己喜欢的地方添加:<a href="$url_head¤cy=USD">美元</a> <a href="$url_head¤cy=GBP">英镑</a> <a href="$url_head¤cy=EUR">欧元</a> <a href="$url_head¤cy=Y">人民币</a> <a href="$url_head¤cy=AUD">澳元</a>自己修改,把RMB改成卢布,然后加上瑞士法郎SEK,加元CAD,代码是:<a href="index.php?currency=USD">USD</a> <a href="index.php?currency=GBP">GBP</a> <a href="index.php?currency=EUR">EUR</a> <a href="index.php?currency=RUB">RUB</a> <a href="index.php?currency=AUD">AUD</a> <a href="index.php?currency=CAD">CAD</a> <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');自己修改代码是:增加代码:$_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将被替换为相应的价格'显示效果:增加以下代码:参考$url_this=":/".$_SERVER'_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'927行下增加代码: $currency=$_SESSION'currency' $rate=explode(',',$GLOBALS'_CFG''rate'); 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($currency='AUD') $price=$price*$rate4; 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 'Y': 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找到1608行参加代码: $order'currency'=$_SESSION'currency'$order'new_money'=price_format_hs($order'order_amount');/* * 汇率转换后的金额 * * 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*$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'_CFG''price_format') case 0: $price = number_format($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 = 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行增加:$_SESSION'currency'='USD'10:修改借口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'9 / 9