ecshop 多货币解决方案(2)

在(1)中只改了购物前显示页面,下来要改购物后使用paypal支付时多货币的页面。

首先先修改数据库,在ecs_order_info表中增加如图所示的两条:

然后打开根目录下的flow.php文件,在$order[‘parent_id’] = $parent_id;后面加入:

$order['currency'] = $_SESSION['currency'];//所选择的货币类型$order['new_money'] = price_format1($order['order_amount']);//选择货币总额

然后找到\includes\modules\payment\paypal这个文件,找到function get_code这个函数,在其内加入

$paypal_currency = $_SESSION["currency"];

找到\include\lib_common.php,在最后加上

//用于支付换算function price_format1($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, '.', '');}return $price;}

下来在后台模板里显示所加的数据,找到\admin\templates\order_list.htm,在35行加入

<th>货币类型</th><th>选择货币后总额</th>

在47行加入

<td align="right" valign="top" nowrap="nowrap">{$order.currency}</td><td align="right" valign="top" nowrap="nowrap">{$order.new_money}</td>

最后找到\admin\order.php,在5000行的sql语句中的select加入o.currency, o.new_money, ,即

$sql = "SELECT o.order_id, o.currency, o.new_money, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid," ."o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " ."(" . order_amount_field('o.') . ") AS total_fee, " ."IFNULL(u.user_name, '" .$GLOBALS['_LANG']['anonymous']. "') AS buyer "." FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " ." LEFT JOIN " .$GLOBALS['ecs']->table('users'). " AS u ON u.user_id=o.user_id ". $where ." ORDER BY $filter[sort_by] $filter[sort_order] "." LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",$filter[page_size]";

在function order_list()的第一行加入$_SESSION[‘currency’] = ‘RMB’;

最重要的是今天的心。

ecshop 多货币解决方案(2)

相关文章:

你感兴趣的文章:

标签云: