如何实现ECSHOP商品详情页面显示购买记录

更新时间:2016-07-01 点击量:1416


有些ecshop用户在使用ecshop模板是自己在网上下载的免费的模板,有时候下载的免费模板相关功能是不齐全的,如我这章说的ecshop模板中没有带商品购买记录,没有这样的一个记录,用户就不能知道你商品的热销程度,无形中会降低商城商品的宣传。

如何解决这个问题呢?我们只要在相关的文档中增加些相关的代码就立马解决这样的问题了,优易软件为大家整理关于如何实现ecshop商品详情页面显示购买记录。操作如下:


在goods.php加入 代码

$smarty->assign('sale_history',      getsales_history($goods_id));        //获取购买历史记录
function getsales_history($goods_id){
$sql ='select f.consignee, f.order_sn, f.address, 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]['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;
}
在goods.dwt中加入 代码
<table width="100%" cellpadding="5" cellspacing="1">
             
                 
历史购买记录
                 
名字
                    
订单号
                    
地址
                    
数量
                    
日期
                
                
                
                    
                 
{
$saleitem.name}
                    
{
$saleitem.order_sn}
                    <td align="center">{$saleitem.address}
                    <td align="center">{$saleitem.number}
                    <td align="center">{$saleitem.add_time}


 
将以上代码写入相关的文档中,ecshop商品详情页面显示购买记录就能立马实现。
更多的精品模板、实用性文章尽在优易软件
                
                
           
支付宝扫码打赏 微信打赏

如果文章对您有帮助,就打赏一个吧

在线客服

客户服务

热线电话:

13128985956 服务时间:

周一到周六:9:00-18:00

在线QQ客服

在线微信客服

关于我们 常见问题

支付方式 加盟合作

提交需求
优惠红包 购物车0 反馈留言 返回顶部