专注ECSHOP第九年
始自2007,服务二千多商户,不断为您增光溢彩

ECSHOP常见二次开发项

(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);
			}
		}
	}

 

未经允许不得转载:阿牛ECSHOP » ECSHOP常见二次开发项
1

Parse error: syntax error, unexpected '}' in /www/wwwroot/blog2018.uuecs.com/wp-content/themes/DUX/comments.php on line 31