天津新亚太工程建设监理有限公司网站,手机网站建设费用价格,怎样找网站,工作纪律生活纪律研讨发言ecshop各个页面调用商品销售量方法(原创可用)ECSHOP模板首页的推荐商品包括热销推荐和促销三个文件只对热销商品为例第一步#xff1a;打开根目录/includes/lib_goods.php文件。在文件末尾添加方法function selled_count($goods_id){$sql select sum(goods_number) as c…ecshop各个页面调用商品销售量方法(原创可用)ECSHOP模板首页的推荐商品包括热销推荐和促销三个文件只对热销商品为例第一步打开根目录/includes/lib_goods.php文件。在文件末尾添加方法function selled_count($goods_id){$sql select sum(goods_number) as count from .$GLOBALS[ecs]-table(order_goods).where goods_id .$goods_id.;$res $GLOBALS[db]-getOne($sql);if($res0){return $res;}else{return(0);}}第二步搜索get_recommend_goods方法在这个方法中找到这句话$goods[$idx][url] build_uri(goods, array(gid $row[goods_id]), $row[goods_name]);在这句话下添加 $goods[$idx][count] selled_count($row[goods_id]);第三步在模版的library/recommend_hot.lbi中在需要的地方添加售出 {$goods.count} 瓶首页分类下的商品实现“已售出”。第一步分类下商品也需要修改lib_goods.php。找到分类下的商品assign_cat_goods方法。在$goods[$idx][url] build_uri(goods, array(gid $row[goods_id]), $row[goods_name]);句话下添加$goods[$idx][count] selled_count($row[goods_id]);第二步需要修改模版文件/library/cat_goods.lbi。在需要的地方添加销售量{$goods.count}在商品分类页面调用已售出第一步修改根目录下category.php找到category_get_goods方法函数中foreach循环添加$arr[$row[goods_id]][count] selled_count($row[goods_id]);第二步文件的最后部分添加函数function selled_count($goods_id){$sql select sum(goods_number) as count from .$GLOBALS[ecs]-table(order_goods).where goods_id .$goods_id.;$res $GLOBALS[db]-getOne($sql);if($res0){return $res;}else{return(0);}}第三步在模版文件goods_list.lbi中需要的地方添加销售量{$goods.count}说明搜索页面需要修改search.php在搜索页面调用已售出多少件第一步打开根目录/search.php在最后加上function selled_count($goods_id){$sql select sum(goods_number) as count from .$GLOBALS[ecs]-table(order_goods).where goods_id .$goods_id.;$res $GLOBALS[db]-getOne($sql);if($res0){return $res;}else{return(0);}}方法第二步在页面搜索$arr[$row[goods_id]][url] build_uri(goods, array(gid $row[goods_id]), $row[goods_name]);在下面添加$arr[$row[goods_id]][count] selled_count($row[goods_id]);第三步打开模版文件/search.dwt在需要的地方调用。销售量{$goods.count}