在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">&nbsp;{$smarty.foreach.n.iteration}</td>
    <td bgcolor="#FFFFFF">&nbsp;<a href="user.php?act=order_detail&order_id={$item.order_id}">{$item.order_sn}</a></td>
    <td bgcolor="#FFFFFF">&nbsp;{$item.user_name}</td>
    <td bgcolor="#FFFFFF">&nbsp;{$item.order_amount}</td>
    <td bgcolor="#FFFFFF">&nbsp;{$item.add_time}</td>
    <td bgcolor="#FFFFFF">&nbsp;{$item.pay_time}</td>
    <td bgcolor="#FFFFFF">&nbsp;{$item.shipping_time}</td>
    <td bgcolor="#FFFFFF">&nbsp;{$item.shipping_name}</td>
    <td bgcolor="#FFFFFF">&nbsp;<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如何在首页显示最近
 来源:中国B4C电子商务