ecshop扩展函数

2009-12-30 17:56 来源:www.chinab4c.com 作者:admin

功能:取得ecshop购物车中所有商品所在的分类

function get_cart_goods_category_id(){
 global $db;
 global $ecs;
 $goods_array = $db -> getAll("select distinct(g.cat_id) from ".$ecs->table('goods')." g , ".$ecs->table('cart')." c where g.goods_id = c.goods_id and c.session_id = '" .SESS_ID ."'");
 $array = array();
 if($goods_array){
  foreach($goods_array as $k => $v){
   $array[] = $v[cat_id];
  }
 }
 return $array;
}

 

功能:获得ecshop订单最后一次操作记录
function get_order_action($order_id){
 global $db;
 global $ecs;
 return  $db-> getOne("select action_note from  ".$ecs->table('order_action')." where order_id = '".$order_id."' order by log_time desc limit 1");

}

//==============
//获得最近订单的函数
//$num为显示记录条数
//返回:购买记录数组
//==============
function get_new_order($num = 10){
 global $db;
 global $ecs;
 $sql = "select o.consignee,og.goods_name,og.goods_price from ".$ecs->table('order_info')." o , ".$ecs->table('order_goods')." og where o.order_id = og.order_id and o.order_status = 1 order by o.add_time limit $num";
 $info = $db -> getAll($sql);
 if($info){
  foreach($info as $k => $v){

   $info[$k]['consignee'] = sub_str($info[$k]['consignee'],1,false).'**';
   $info[$k]['goods_name'] = sub_str($info[$k]['goods_name'],4,false).'**';
   $info[$k]['goods_price'] =  price_format($v['goods_price']);
  }
 }
 return $info;
}

注册送金额

log_account_change($_SESSION['user_id'], 50,  0,  0,  0, '注册赠送资金:50');//注册总送资金

5:取得最高等级分类

function get_first_parent($cat_id=0){
 global $db;
 global $ecs;
 $parent = '';
 if($cat_id){
  $parent = $db -> getOne("select parent_id from ".$ecs->table('category')." where cat_id = $cat_id");
 }
 if($parent == 0){
  return $cat_id;
 }else{
  return get_first_parent($parent);
 }
}

来源:中国B4C电子商务