Ecshop后台订单精准统计有助精准营销
显示IP,来源网站等信息,通过这些信息能帮助你更好的掌握潜在客户的来源与分布,为精准营销提供条件
修改文件:/languages/zh_cn/admin/common.php,添加如下代码:
$_LANG['order_tongji'] = ’订单统计’;
修改文件:/admin/includes/inc_menu.php,添加
/* 二次开发 订单统计 */
$modules['06_stats']['order_tongji'] = ’order_tongji.php?act=list’;
创建文件:/admin/order_tongji.php
<?php
define(‘IN_ECS’, true);
require(dirname(__FILE__) . ’/includes/init.php’);
require(dirname(__FILE__) . ’/includes/cls_page.php’);
/*—————————————————— */
/*—————————————————— */
if ($_REQUEST['act'] == ’list’)
{
$sql=urlencode(“SELECT * FROM ” .$ecs->table(‘tongji’).“ as t right join ” .$ecs->table(‘order_info’).“ as i on t.order_sn=i.order_sn order by tongji_id desc”);
$pclass=new Page($sql,20,10,“”,“”,“”,“”);
$pclass->SetPagePara(“par”,“paravalue”);
$pclass->ShowList($_GET["startpage"],$_GET["t"],$_GET["offset"],“order_tongji.php”,“act=list”);
$i=’1′;
$html = ”;
while($row=mysql_fetch_row($pclass->Result))
{
$html .= ’<tr>’;
$html .= ’<td>’.$row[0].’</td>’;
$html .= ’<td>’.$row[1].’</td>’;
$html .= ’<td>’.$row[2].’</td>’;
$html .= ’<td>’.date(‘Y-m-d H:i:s’,$row[4]+28800).’</td>’;
$html .= ’<td>’.$row[6].’</td>’;
$html .= ’<td>’.$row[5].’</td>’;
$html .= ’<td>’.$row[7].’</td>’;
$html .= ’<td>’.$row[8].’</td>’;
$html .= ’</tr>’;
}
$smarty->assign(‘page’, $pclass->OutPut);
$smarty->assign(‘content’, $html);
$smarty->display(‘tongji.htm’);
}
?>
创建文件:/admin/templates/tongji.htm
{include file=“pageheader.htm”}
<div class=“list-div” id=“listDiv”>
<table width=“100%” border=“0″ cellpadding=“3″ cellspacing=“1″>
<tr>
<th>编号</th>
<th>订单号</th>
<th>收货人</th>
<th>下单时间</th>
<th>ip</th>
<th>来源网站</th>
<th>来源URL</th>
<th>受访URL</th>
</tr>
{$content}
<tr><td colspan=“8″ align=“center”><BR>{$page}</td></tr>
</table>
</div>
{include file=“pagefooter.htm”}
修改文件 /flow.php 1246行左右,添加如下代码
if(isset($_COOKIE['request_info'])){
$request_info = unserialize(strtr($_COOKIE['request_info'],array(“\”=>”“)));
$sql = ”INSERT INTO “.$ecs->table(‘tongji’).”(order_sn, user_name,start_time,end_time,host,ip,start_url,end_url) value(‘“.$order['order_sn'].”‘,’“.$order['c**ignee'].”‘,’“.$request_info['time'].”‘,’“.gmtime().”‘,’“.$request_info['host'].”‘,’“.$_SERVER['REMOTE_ADDR'].”‘,’“.$request_info['start_url'].”‘,’“.$request_info['end_url'].”‘)“;
}else{
$sql = ”INSERT INTO “.$ecs->table(‘tongji’).”(order_sn, user_name,start_time,end_time,host,ip,start_url,end_url) value(‘“.$order['order_sn'].”‘,’“.$order['c**ignee'].”‘,’“.gmtime().”‘,’“.gmtime().”‘,’本站’,’“.$_SERVER['REMOTE_ADDR'].”‘,’本站’,'本站’)”;
}
$db->query($sql);
修改文件 include/init.php,添加
/* 记录请求信息 */
function request_info(){
$start_url = $_SERVER['HTTP_REFERER']; //来源网站
$start_url_info = parse_url($start_url);
if($start_url_info['host']!=$_SERVER['SERVER_NAME'] && $start_url_info['host']!=”){
$request_info = array();
$request_info['host'] = $start_url_info['host']; //域名
$request_info['time'] = gmtime(); //时间
$request_info['start_url'] = $start_url; //时间
$request_info['end_url'] = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; //被访页面
setcookie(‘request_info’, serialize($request_info), time()+86400, “/”);
}
}
request_info();