找人開發還花錢,在這里小編輯把最常開發項分享給大家
(1)ECSHOP獲取商品的銷量
/includes/lib_insert.php,在最下面增加一個函數(注意別加在 “?>”外面 增加:
function insert_sales($arr)
//調用ecshop所有銷量總數
{
$db = $GLOBALS['db'];
$ecs = $GLOBALS['ecs'];
$goods_id = $arr['id'];
$sql = "select sum(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id . " and o.order_status=5 " ;
if (($GLOBALS['db']->getOne($sql)) == ""){
return "0";
}else{
return $GLOBALS['db']->getOne($sql);
}
}
調用:
詳細頁調用:
已銷售:{insert name='sales' id=$id}
分類頁調用:
已銷售:{insert name='sales' id=$goods.goods_id}
(2)獲取ECSHOP評論總數
打開includesb_insert.php 文件,在最下面增加一個函數(注意別加在 “?>”外面 )
// 調用ecshop評論信息條數
function insert_commentnum($arr)
{
$count=$GLOBALS['db']->getOne('SELECT COUNT(*) FROM '. $GLOBALS['ecs']->table('comment')."WHERE id_value='$arr[id]'". "AND comment_type='$arr[type]' AND status = 1 AND parent_id = 0");
return $count;
}
(3)后臺刪除商品的同時,刪除商品描述圖。
打開admin/goods.php 約1685行。
$sql = "SELECT goods_id, goods_name,
增加:goods_desc,
搜索:
if (!empty($goods['original_img']))
{
@unlink('../' . $goods['original_img']);
}
后增加:
if($goods['goods_desc']){
preg_match_all("/<img(.*?)src=/"(.*?)/"[^>]*//>/is",$goods['goods_desc'],$arr);
if($arr[2]){//BY UUECS_Com
foreach($arr[2] as $k => $v){
@unlink("../".$v);
}
}
}
新聞熱點
疑難解答