ECShop怎么实现已售出多少件功能
1个回答
展开全部
1.在根目录下找 category.php , 查找
$arr[$row['goods_id']]['url']
在底下添加以下代码:
/*** 已出售多少件 , 直接使用smarty 的insert 调用该方法 , 使用在goods_lbi文件中 ***/
function insert_selectNum($arr){
$goods_id = $arr["goods_id"];
$sql = 'selectNULLM(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 g.goods_id = '$goods_id'" . $ext;
$sales_count_num = $GLOBALS['db']->getOne($sql);
//echo $sql."==== 测试是否有数据输入";
return $sales_count_num;
}
2.在themes\default\library 目录下找 goods_list.lbi 查找
修改前请注意备份源文件。
==========================================================================================
ecshop商品详细页显示已售商品数量和评论数量
ecshop增加已售数量和评论数量很简单,步骤如下,原创文章转载请指明同盟者网络http://blog.sina.com.cn/tomener
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}-->
$arr[$row['goods_id']]['url']
在底下添加以下代码:
/*** 已出售多少件 , 直接使用smarty 的insert 调用该方法 , 使用在goods_lbi文件中 ***/
function insert_selectNum($arr){
$goods_id = $arr["goods_id"];
$sql = 'selectNULLM(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 g.goods_id = '$goods_id'" . $ext;
$sales_count_num = $GLOBALS['db']->getOne($sql);
//echo $sql."==== 测试是否有数据输入";
return $sales_count_num;
}
2.在themes\default\library 目录下找 goods_list.lbi 查找
修改前请注意备份源文件。
==========================================================================================
ecshop商品详细页显示已售商品数量和评论数量
ecshop增加已售数量和评论数量很简单,步骤如下,原创文章转载请指明同盟者网络http://blog.sina.com.cn/tomener
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}-->
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询