ecshop商品详细页显示已售商品数量和评论数量
发布:smiling 来源: PHP粉丝网 添加日期:2014-11-15 09:08:53 浏览: 评论:0
ecshop增加已售数量和评论数量很简单,步骤如下.
1.在ecshop程序goods.php页面最下面加入这两个函数:
- function get_buy_sum($goods_id)
- {
- $sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' .
- 'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' .
- $GLOBALS['ecs']->table('order_goods') . ' AS g ' .
- "WHERE o.order_id = g.order_id " .
- "AND o.order_status = '" . OS_CONFIRMED . "' " .
- "AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .
- " AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .
- " AND g.goods_id = '$goods_id'";
- return $GLOBALS['db']->getOne($sql);
- }
- function get_comment_num($goods_id) {
- $sql= "select count(*) from ".$GLOBALS['ecs']->table('comment')." where id_value='".$goods_id."' AND status = 1";
- return $GLOBALS['db']->getOne($sql);
- }
2.在ecshop程序goods.php中加入:
$smarty->assign('buy_num',get_buy_sum($goods_id));
$smarty->assign('comment_num',get_comment_num($goods_id));
在$smarty->display('goods.dwt',$cache_id);之前哈.
3.ecshop中goods.dwt模板中加这个:
累计售出:{$buy_num}//开源软件:phpfensi.com
评论数量:{$comment_num}
PS:实践发现此方法只实用于goods页面,其他页面无法调用.
Tags: ecshop商品详细页 ecshop评论数量
相关文章
- ·ECSHOP商品列表调用评论数量实现方法(2015-04-04)
- ·ECSHOP调用商品评论数量(2015-09-28)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)