ECShop 显示 年 月 日 销售量


商品详情页显示累计售出量
1、对于交易量很大的网站,每个商品的“累计售出”个数可能随时都在变化,
所以本方法使用了 insert 函数来实现,以达到能体现实时最新的销售量(也就是销售量不会被缓存)

 

 


2、修改 includes/lib_insert.php 文件
在最下面增加一个函数 

/**
 * 显示销售排行
 *
 * @access  	public
 * @parameter 	string 参数由$arr['type']来决定,如果name为空,那么输出所有,否者按照Y,M,D来决定输出年销量,月销量,日销量
 * @return  	string
 * @author      By Caige in stu 2013.1.28
 */
function insert_goods_sale_num($arr)
{
	  $timeLimit = "";
	  //echo $arr['type'];
	  if($arr['type']){
	  	switch($arr['type']){
		  	case "Y": $timeLimit = strtotime("-1 years"); break;
		  	case "M": $timeLimit = strtotime('-1 months'); break;
		  	case "D": $timeLimit = strtotime('-1 days'); break;
		  	default :	$timeLimit ="";
	  	}
	  	$timeLimit = " AND confirm_time between ".$timeLimit." and ".strtotime('now').";";
	  }
	  //echo '<br/>'.$timeLimit.'<br/>';
    $sql = 'SELECT SUM(goods_number) AS number ' .
           ' FROM ' . $GLOBALS['ecs']->table('order_goods') ." AS og , " . $GLOBALS['ecs']->table('order_info') ." AS  o ".
           " WHERE og.order_id = o.order_id and og.goods_id=".$arr['goods_id'].$timeLimit;
           
    //echo '<br/>'.$sql.'<br/>';
    $row = $GLOBALS['db']->GetRow($sql);
    if ($row)
    {
        $number = intval($row['number']);
    }
    else
    {
        $number = 0;
    }
    return $number;
}

 

 

 

3、在 goods.dwt 下

加上

<p><span>日销量:</strong>{insert name='goods_sale_num'   goods_id=$goods.goods_id type='D'} </p>
<p><span>月销量:</strong>{insert name='goods_sale_num'   goods_id=$goods.goods_id type='M'} </p>
<p><span>年销量:</strong>{insert name='goods_sale_num'   goods_id=$goods.goods_id type='Y'} </p>

 

神奇的销量出现了

 

参考:http://www.ecshop119.com/article-433.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值