码迷,mamicode.com
首页 > 其他好文 > 详细

ecshop商品详情页面显示购买记录

时间:2015-08-30 15:37:02      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

1.在goods.php中写入代码:

//购买的历史记录
function getsales_history($goods_id){
$sql =‘select f.consignee, f.order_sn, f.address,g.goods_name,g.goods_number,f.add_time FROM ‘. $GLOBALS[‘ecs‘]->table(‘order_goods‘) .‘ as g,‘. $GLOBALS[‘ecs‘]->table(‘order_info‘) .‘ as f where g.order_id = f.order_id and g.goods_id=‘.$goods_id;
$res = $GLOBALS[‘db‘]->getAll($sql);
$sales_history = array();
foreach ($res AS $idx => $row){
   $sales_history[$idx][‘name‘]       = $row[‘consignee‘];
   $sales_history[$idx][‘order_sn‘]       = $row[‘order_sn‘];
   $sales_history[$idx][‘address‘]       = $row[‘address‘];
   $sales_history[$idx][‘number‘]       = $row[‘goods_number‘];
   $sales_history[$idx][‘goods_name‘]       = $row[‘goods_name‘];
  // $sales_history[$idx][‘add_time‘]       = local_date("Y-m-d", $row[‘add_time‘]);
   $sales_history[$idx][‘add_time‘]       = local_date($GLOBALS[‘_CFG‘][‘time_format‘], $row[‘add_time‘]);
 
}
  return $sales_history;
}


2.在大概240行作于插入:

$smarty->assign(‘sale_history‘,      getsales_history($goods_id));        //获取购买历史记录


3.在goods.dwt页面写上:

<table width="100%" cellpadding="5" cellspacing="1">
             <tr>
                 <th>历史购买记录</th>
                 <th>名字</th>
                    <th>订单号</th>
<th>商品名称</th>
                    <th>地址</th>
                    <th>数量</th>
                    <th>日期</th>
                </tr>
                <!--{foreach from=$sale_history item=saleitem}-->
                <tr>
                    <td></td>
                 <td>{$saleitem.name}</td>
                    <td>{$saleitem.order_sn}</td>
<td>{$saleitem.goods_name}</td>
                    <td align="center">{$saleitem.address}</td>
                    <td align="center">{$saleitem.number}</td>
                    <td align="center">{$saleitem.add_time}</td>
                </tr>
                <!--{/foreach}-->
            </table>

 



ecshop商品详情页面显示购买记录

标签:

原文地址:http://www.cnblogs.com/yundu/p/4770796.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!