ecshop商品详细页显示已售商品数量和评论数量
2014-04-29 18:43
453 查看
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模板中加这个,大概在221行
<!-- {if $buy_num} 已出售量-->
<li class="clearfix">
<dd>
<strong>累计售出:</strong>{$buy_num}
</dd>
</li>
<!--{/if}-->
<!-- {if $comment_num} 评论数量-->
<li class="clearfix">
<dd>
<strong>评论数量:</strong><a href="#comment">{$comment_num}</a>
</dd>
</li>
<!--{/if}-->
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模板中加这个,大概在221行
<!-- {if $buy_num} 已出售量-->
<li class="clearfix">
<dd>
<strong>累计售出:</strong>{$buy_num}
</dd>
</li>
<!--{/if}-->
<!-- {if $comment_num} 评论数量-->
<li class="clearfix">
<dd>
<strong>评论数量:</strong><a href="#comment">{$comment_num}</a>
</dd>
</li>
<!--{/if}-->
相关文章推荐
- Struts2 Tomcat class.classLoader.resources.dirContext.docBase赋值造成的DoS及远程代码执行利用!
- Centos安装Zabbix
- 网站缓存策略
- Windows和Linux之间实现资源共享——Samba服务器
- 入职体验--linux学习体会
- 在ecshop 首页中实现增加刷选功能
- Linux进程的实际用户ID和有效用户ID
- 《CSS网站布局实录》学习笔记(六)
- centos中安装PyMongo库
- tableView:canEditRowAtIndexPath: crash when popping viewController
- apache+tomcat集群 实现负载均衡和session复制
- 中国四大门户网站
- make:***[out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o]Error1
- 如何使用 DevExpress MVVM 架构构建具有 DOCK 能力的 MVVM 程序?
- linux系统性能监控
- error opening trace file: No such file or directory (2)报错原因
- windows下通过cygwin来使用hadoop
- CentOS环境 升级Python2.6.6至2.7.5
- input 子系统架构总结
- 初识OPC