ecshop二次开发首页显示订单

2010-01-08 15:20 来源:www.chinab4c.com 作者:admin

//==============
//获得最近订单的函数
//$num为显示记录条数
//返回:购买记录数组
//==============
function get_new_order($num = 10){
 global $db;
 global $ecs;
 $sql = "select o.consignee,og.goods_name,og.goods_price from ".$ecs->table('order_info')." o , ".$ecs->table('order_goods')." og where o.order_id = og.order_id and o.order_status = 1 order by o.add_time limit $num";
 $info = $db -> getAll($sql);
 if($info){
  foreach($info as $k => $v){

   $info[$k]['consignee'] = sub_str($info[$k]['consignee'],1,false).'**';
   $info[$k]['goods_name'] = sub_str($info[$k]['goods_name'],8,false).'**';
   $info[$k]['goods_price'] =  price_format($v['goods_price']);
  }
 }
 $GLOBALS['smarty']-> assign('orderlist',$info);
 //return $info;
}


调用模板
  <!--{if $invoice_list}-->
<style type="text/css">
.boxCenterList form{display:inline;}
.boxCenterList form a{color:#404040; text-decoration:underline;}
</style>
<div class="box">
 <div class="box_1">
  <h3><span>最新订单</span></h3>
  <div class="boxCenterList">
  <table>
   {foreach from=$orderlist item=item}
   <tr><td>{$item.consignee}</td><td>&nbsp;{$item.goods_name}</td><td>&nbsp;{$item.goods_price}</td></tr>
 
   {/foreach}
   </table>
  </div>
 </div>
</div>
<div class="blank5"></div>
<!-- {/if} -->

php调用
 get_new_order();