ecshop 详情页面获取商品销量和评论数
添加頁面:根目錄下面的goods.php 找到
/* 記錄瀏覽歷史 */
if (!empty($_COOKIE['ECS']['history']))
......
添加代碼如下:
/*新添加的程序 ?獲取銷量和評(píng)論數(shù)*/
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'";
? $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 " . db_create_in(array(OS_CONFIRMED, OS_SPLITED, OS_SPLITING_PART)) .
? ? ? " 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);
}
$smarty->assign('buy_num',get_buy_sum($goods_id));
$smarty->assign('comment_num',get_comment_num($goods_id));
轉(zhuǎn)載于:https://blog.51cto.com/taoyouth/1406188
總結(jié)
以上是生活随笔為你收集整理的ecshop 详情页面获取商品销量和评论数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于iscsi实现文件存储共享
- 下一篇: mysql主从复制及失败切换