在ecshop前台显示ecshop订单列表
2009-08-30 18:38 来源:www.chinab4c.com 作者:ecshop专家
在使用ecshop电子商务系统的过程中,我们常常会想把最近或者是部分订单信息列表出来。这样可以方便客户浏览.那么ecshop如何做到呢.首先,新建下面的页面.用于检索ecshop订单
<?php
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
if (empty($_REQUEST['act']))
{
//默认显示页面
$_REQUEST['act'] = 'main';
}
assign_template();
assign_dynamic('snatch');
$smarty->assign('page_title', $position['title']);
$smarty->assign('ur_here', $position['ur_here']);
$smarty->assign('helps', get_shop_help());
$sql = 'SELECT o.shipping_name, o.add_time, o.province,o.city,o.district,o.order_id,o.order_sn, o.user_id, o.invoice_no, o.pay_time, s.shipping_code ,(o.order_amount+o.money_paid) as order_amount, o.goods_amount , o.shipping_time , o.pay_time ,o.consignee,o.address FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o' .
' LEFT JOIN ' . $GLOBALS['ecs']->table('shipping') . ' AS s ON s.shipping_id = o.shipping_id' ;
$re = $db->getAll($sql);
$record_count = count($re);
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
$pager = get_pager('order_query.php', array(), $record_count, $page, 5);
$msg_lists = index_get_invoice_query($pager['start'],5);
$smarty -> assign('list',$msg_lists);
$smarty->assign('pager', $pager);
$smarty -> display('order_query.dwt');
function index_get_invoice_query($start,$size)
{ global $ecs;
global $db;
$sql = 'SELECT o.shipping_name, o.add_time, o.province,o.city,o.district,o.order_id,o.order_sn, o.user_id, o.invoice_no, o.pay_time, s.shipping_code ,(o.order_amount+o.money_paid) as order_amount, o.goods_amount , o.shipping_time , o.pay_time ,o.consignee,o.address FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o' .
' LEFT JOIN ' . $GLOBALS['ecs']->table('shipping') . ' AS s ON s.shipping_id = o.shipping_id' .
' ORDER BY shipping_time DESC LIMIT '.$start.','. $size;
$all = $GLOBALS['db']->getAll($sql);
foreach ($all AS $key => $row)
{ $str="";
$plugin = ROOT_PATH . 'includes/modules/shipping/' . $row['shipping_code'] . '.php';
$all[$key]['shipping_time'] = local_date("m-d",$row['shipping_time']); //Y-m-d H:i:s
$all[$key]['pay_time'] = local_date("m-d",$row['pay_time']); //Y-m-d H:i:s
if($row['province']){
$str.= $GLOBALS['db'] -> getOne("select region_name from".$ecs->table('region')." where region_id = ".$row['province']);
}
if($row['city']){
$str.= $GLOBALS['db'] -> getOne("select region_name from".$ecs->table('region')." where region_id = ".$row['city']);
}
if($row['district']){
$str.= $GLOBALS['db'] -> getOne("select region_name from".$ecs->table('region')." where region_id = ".$row['district']);
}
//$all[$key]['address'] = $all[$key]['province'].$all[$key]['district'].$all[$key]['district']."***";
$all[$key]['consignee'] = trim(sub_str($row['consignee'],1),".")."**";
$all[$key]['address'] = $str. "***";
$all[$key]['add_time'] = local_date('Y-m-d',$row['add_time']);
$all[$key]['pay_time'] = local_date('Y-m-d',$row['pay_time']);
$all[$key]['order_amount'] = price_format($row['order_amount'],false);
$all[$key]['user_name'] = $db -> getOne("select user_name from".$ecs->table('users')." where user_id =".$row['user_id']);
if (file_exists($plugin))
{
include_once($plugin);
$shipping = new $row['shipping_code'];
$all[$key]['invoice_no'] = $shipping->query((string)$row['invoice_no']);
}
}
clearstatcache();
return $all;
}
?>
其次,编写以下模板,用来显示订单的信息,而且起用分页函数,对订单列表进行分页面.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<meta name="Keywords" content="{$keywords}" />
<meta name="Description" content="{$description}" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>{$page_title}</title>
<!-- TemplateEndEditable --><!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" href="animated_favicon.gif" type="image/gif" />
<link href="{$ecs_css_path}" rel="stylesheet" type="text/css" />
{* 包含脚本文件 *}
{insert_scripts files='common.js'}
</head>
<body>
<!-- #BeginLibraryItem "/library/page_header.lbi" --><!-- #EndLibraryItem -->
<!--当前位置 start-->
<div class="block box">
<div id="ur_here">
<!-- #BeginLibraryItem "/library/ur_here.lbi" --><!-- #EndLibraryItem -->
</div>
</div>
<!--当前位置 end-->
<div style="text-align:center">
<table width="960" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="18" bgcolor="#FFFFFF">序号</td>
<td bgcolor="#FFFFFF">订单号</td>
<td bgcolor="#FFFFFF">下单用户</td>
<td bgcolor="#FFFFFF">订单金额</td>
<td bgcolor="#FFFFFF">下单时间</td>
<td bgcolor="#FFFFFF">付款时间</td>
<td bgcolor="#FFFFFF">发货时间</td>
<td bgcolor="#FFFFFF">发货方式</td>
<td bgcolor="#FFFFFF">订单详情</td>
</tr>
{foreach from = $list item=item name=n}
<tr>
<td bgcolor="#FFFFFF"> {$smarty.foreach.n.iteration}</td>
<td bgcolor="#FFFFFF"> <a href="user.php?act=order_detail&order_id={$item.order_id}">{$item.order_sn}</a></td>
<td bgcolor="#FFFFFF"> {$item.user_name}</td>
<td bgcolor="#FFFFFF"> {$item.order_amount}</td>
<td bgcolor="#FFFFFF"> {$item.add_time}</td>
<td bgcolor="#FFFFFF"> {$item.pay_time}</td>
<td bgcolor="#FFFFFF"> {$item.shipping_time}</td>
<td bgcolor="#FFFFFF"> {$item.shipping_name}</td>
<td bgcolor="#FFFFFF"> <a href="user.php?act=order_detail&order_id={$item.order_id}">查看</a></td>
</tr>
{/foreach}
<tr>
<td colspan="9" bgcolor="#FFFFFF"><!-- #BeginLibraryItem "/library/pages.lbi" --><!-- #EndLibraryItem -->
</td>
</tr>
</table>
</div>
<!--帮助-->
<div class="block">
<div class="box">
<div class="helpTitBg clearfix">
<!-- #BeginLibraryItem "/library/help.lbi" --><!-- #EndLibraryItem -->
</div>
</div>
</div>
<div class="blank"></div>
<!-- #BeginLibraryItem "/library/page_footer.lbi" --><!-- #EndLibraryItem -->
</body>
</html>
相关文章:
最近更新
常用插件
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...