ECSHOP的发货流程的确很费事,要操作好几步才能够,通这本教程,就能够完结一键发货功用,只需在订单概况中填写快递单号点击按钮即可发货完结。
1、订单列表中,假如是已付款但还未发货的订单,就会显现一键发货按钮,轻松辨认未发货订单,如下图:
点击进入订单概况页,然后订单概况中,如下图。
教程开端:
第一步:翻开admintemplatesorder_info.htm
查找:
<formaction="order.php?act=operate"method="post"name="theForm">
在下面增加以下代码:
<!--一键发货--><pclass="list-p"style="margin-bottom:5px"><tablewidth="100%"cellpadding="3"cellspacing="1"><tr><thcolspan="2">一键承认并发货</th></tr><tr><tdwidth="18%"><palign="right"><strong>发货单号:</strong></p></td><tdwidth="82%">{if$order.pay_status==2&&$order.shipping_status!=1&&$order.order_status==1}<inputname="invoice_no"type="text"style="color:#00F"value=""/><inputname="to_shipping"type="submit"style="color:#F00"value="一键承认并发货"class="button"/>{/if}(填写快递单号,履行此操作后一个订单不论之前是否承认都将被设置为已承认、已发货状况,一起记载下快递单号。)</td></tr></table></p><!--一键发货-->
查找:第2步:翻开admintemplatesorder_list.htm
<th><ahref="javascript:listTable.sort('consignee','DESC');">{$lang.consignee}</a>{$sort_consignee}</th>
在下面增加以下代码:
<th><ahref="javascript:listTable.sort('shipping','DESC');">配送方法</a>{$sort_shipping}</th>
持续查找:
<tdalign="left"valign="top"><ahref="mailto:{$order.email}">{$order.consignee|escape}</a>{if$order.tel}[TEL:{$order.tel|escape}]{/if}<br/>{$order.address|escape}</td>
在下面增加以下代码:
<tdalign="center"valign="top">{$order.shipping_name}<br/>{if$order.invoice_no}{$order.invoice_no}{elseif$order.pay_status==2&&$order.shipping_status!=1&&$order.order_status==1}<ahref="order.php?act=info&order_id={$order.order_id}"style="background:#208494;color:#fff;padding:5px;text-decoration:none;">一键承认并发货</a>{/if}</td>
第三步:翻开adminorder.php
查找:
/*承认*/if(isset($_POST['confirm'])){$require_note=false;$action=$_LANG['op_confirm'];$operation='confirm';}
在下面增加以下代码:
/*------------------------------------------------------*///--start一键发货/*------------------------------------------------------*/elseif(isset($_POST['to_shipping'])){$invoice_no=empty($_REQUEST['invoice_no'])?'':trim($_REQUEST['invoice_no']);//快递单号if(!empty($invoice_no)){$order_id=intval(trim($order_id));$action_note=trim($action_note);/*查询:依据订单id查询订单信息*/if(!empty($order_id)){$order=order_info($order_id);}else{die('orderdoesnotexist');}/*查询:依据订单是否完结查看权限*/if(order_finished($order)){admin_priv('order_view_finished');}else{admin_priv('order_view');}/*查询:假如管理员归于某个办事处,查看该订单是否也归于这个办事处*/$sql="SELECTagency_idFROM".$ecs->table('admin_user')."WHEREuser_id='$_SESSION[admin_id]'";$agency_id=$db->getOne($sql);if($agency_id>0){if($order['agency_id']!=$agency_id){sys_msg($_LANG['priv_error'],0);}}/*查询:获得用户名*/if($order['user_id']>0){$user=user_info($order['user_id']);if(!empty($user)){$order['user_name']=$user['user_name'];}}/*查询:获得区域名*/$order['region']=$db->getOne($sql);/*查询:其他处理*/$order['order_time']=local_date($_CFG['time_format'],$order['add_time']);$order['invoice_no']=$order['shipping_status']==SS_UNSHIPPED||$order['shipping_status']==SS_PREPARING?$_LANG['ss'][SS_UNSHIPPED]:$order['invoice_no'];/*查询:是否保价*/$order['insure_yn']=empty($order['insure_fee'])?0:1;/*查询:是否存在实体产品*/$exist_real_goods=exist_real_goods($order_id);/*查询:获得订单产品*/$_goods=get_order_goods(array('order_id'=>$order['order_id'],'order_sn'=>$order['order_sn']));$attr=$_goods['attr'];$goods_list=$_goods['goods_list'];unset($_goods);/*查询:产品已发货数量此单可发货数量*/if($goods_list){foreach($goods_listas$key=>$value){}foreach($goods_listas$key=>$goods_value){if(!$goods_value['goods_id']){continue;}/*超级礼包*/if(($goods_value['extension_code']=='package_buy')&&(count($goods_value['package_goods_list'])>0)){$goods_list[$key]['package_goods_list']=package_goods($goods_value['package_goods_list'],$goods_value['goods_number'],$goods_value['order_id'],$goods_value['extension_code'],$goods_value['goods_id']);foreach($goods_list[$key]['package_goods_list']as$pg_key=>$pg_value){$goods_list[$key]['package_goods_list'][$pg_key]['readonly']='';/*运用库存是否缺货*/if($pg_value['storage']<=0&&$_CFG['use_storage']=='1'&&$_CFG['stock_dec_time']==SDT_SHIP){$goods_list[$key]['package_goods_list'][$pg_key]['send']=$_LANG['act_good_vacancy'];$goods_list[$key]['package_goods_list'][$pg_key]['readonly']='readonly="readonly"';}/*将现已悉数发货的产品设置为只读*/elseif($pg_value['send']<=0){$goods_list[$key]['package_goods_list'][$pg_key]['send']=$_LANG['act_good_delivery'];$goods_list[$key]['package_goods_list'][$pg_key]['readonly']='readonly="readonly"';}}}else{$goods_list[$key]['sended']=$goods_value['send_number'];$goods_list[$key]['sended']=$goods_value['goods_number'];$goods_list[$key]['send']=$goods_value['goods_number']-$goods_value['send_number'];$goods_list[$key]['readonly']='';/*是否缺货*/if($goods_value['storage']<=0&&$_CFG['use_storage']=='1'&&$_CFG['stock_dec_time']==SDT_SHIP){$goods_list[$key]['send']=$_LANG['act_good_vacancy'];$goods_list[$key]['readonly']='readonly="readonly"';}elseif($goods_list[$key]['send']<=0){$goods_list[$key]['send']=$_LANG['act_good_delivery'];$goods_list[$key]['readonly']='readonly="readonly"';}}}}$suppliers_id=0;$delivery['order_sn']=trim($order['order_sn']);$delivery['add_time']=trim($order['order_time']);$delivery['user_id']=intval(trim($order['user_id']));$delivery['how_oos']=trim($order['how_oos']);$delivery['shipping_id']=trim($order['shipping_id']);$delivery['shipping_fee']=trim($order['shipping_fee']);$delivery['consignee']=trim($order['consignee']);$delivery['address']=trim($order['address']);$delivery['country']=intval(trim($order['country']));$delivery['province']=intval(trim($order['province']));$delivery['cit']=intval(trim($order['city']));$delivery['district']=intval(trim($order['district']));$delivery['sign_building']=trim($order['sign_building']);$delivery['email']=trim($order['email']);$delivery['zipcode']=trim($order['zipcode']);$delivery['tel']=trim($order['tel']);$delivery['mobile']=trim($order['mobile']);$delivery['best_time']=trim($order['best_time']);$delivery['postscript']=trim($order['postscript']);$delivery['how_oos']=trim($order['how_oos']);$delivery['insure_fee']=floatval(trim($order['insure_fee']));$delivery['shipping_fee']=floatval(trim($order['shipping_fee']));$delivery['agency_id']=intval(trim($order['agency_id']));$delivery['shipping_name']=trim($order['shipping_name']);/*查询订单信息*/$order=order_info($order_id);/*查看能否操作*/$operable_list=operable_list($order);/*初始化提示信息*/$msg='';/*界说当时时刻*/define('GMTIME_UTC',gmtime());//获取UTC时刻戳/*获得订单产品*/$_goods=get_order_goods(array('order_id'=>$order_id,'order_sn'=>$delivery['order_sn']));$goods_list=$_goods['goods_list'];/*查看此单发货产品库存缺货状况*//*$goods_list现已过处理超值礼包中产品库存已获得*/$virtual_goods=array();$package_virtual_goods=array();/*生成发货单*//*获取发货单号和流水号*/$delivery['delivery_sn']=get_delivery_sn();$delivery_sn=$delivery['delivery_sn'];/*获取当时操作员*/$delivery['action_user']=$_SESSION['admin_name'];/*获取发货单生成时刻*/$delivery['update_time']=GMTIME_UTC;$delivery_time=$delivery['update_time'];$sql="selectadd_timefrom".$GLOBALS['ecs']->table('order_info')."WHEREorder_sn='".$delivery['order_sn']."'";$delivery['add_time']=$GLOBALS['db']->GetOne($sql);/*获取发货单所属供货商*/$delivery['suppliers_id']=$suppliers_id;/*设置默认值*/$delivery['status']=2;//正常$delivery['order_id']=$order_id;/*过滤字段项*/$filter_fileds=array('order_sn','add_time','user_id','how_oos','shipping_id','shipping_fee','consignee','address','country','province','city','district','sign_building','email','zipcode','tel','mobile','best_time','postscript','insure_fee','agency_id','delivery_sn','action_user','update_time','suppliers_id','status','order_id','shipping_name');$_delivery=array();foreach($filter_filedsas$value){$_delivery[$value]=$delivery[$value];}/*发货单入库*/$query=$db->autoExecute($ecs->table('delivery_order'),$_delivery,'INSERT','','SILENT');$delivery_id=$db->insert_id();if($delivery_id){$delivery_goods=array();//发货单产品入库if(!empty($goods_list)){foreach($goods_listas$value){//产品(实货)(虚货)if(empty($value['extension_code'])||$value['extension_code']=='virtual_card'){$delivery_goods=array('delivery_id'=>$delivery_id,'goods_id'=>$value['goods_id'],'product_id'=>$value['product_id'],'product_sn'=>$value['product_sn'],'goods_id'=>$value['goods_id'],'goods_name'=>$value['goods_name'],'brand_name'=>$value['brand_name'],'goods_sn'=>$value['goods_sn'],'send_number'=>$value['goods_number'],'parent_id'=>0,'is_real'=>$value['is_real'],'goods_attr'=>$value['goods_attr']);/*假如是货品*/if(!empty($value['product_id'])){$delivery_goods['product_id']=$value['product_id'];}$query=$db->autoExecute($ecs->table('delivery_goods'),$delivery_goods,'INSERT','','SILENT');$sql="UPDATE".$GLOBALS['ecs']->table('order_goods')."SETsend_number=".$value['goods_number']."WHEREorder_id='".$value['order_id']."'ANDgoods_id='".$value['goods_id']."'";$GLOBALS['db']->query($sql,'SILENT');}//产品(超值礼包)elseif($value['extension_code']=='package_buy'){foreach($value['package_goods_list']as$pg_key=>$pg_value){$delivery_pg_goods=array('delivery_id'=>$delivery_id,'goods_id'=>$pg_value['goods_id'],'product_id'=>$pg_value['product_id'],'product_sn'=>$pg_value['product_sn'],'goods_name'=>$pg_value['goods_name'],'brand_name'=>'','goods_sn'=>$pg_value['goods_sn'],'send_number'=>$value['goods_number'],'parent_id'=>$value['goods_id'],//礼包ID'extension_code'=>$value['extension_code'],//礼包'is_real'=>$pg_value['is_real']);$query=$db->autoExecute($ecs->table('delivery_goods'),$delivery_pg_goods,'INSERT','','SILENT');$sql="UPDATE".$GLOBALS['ecs']->table('order_goods')."SETsend_number=".$value['goods_number']."WHEREorder_id='".$value['order_id']."'ANDgoods_id='".$pg_value['goods_id']."'";$GLOBALS['db']->query($sql,'SILENT');}}}}}else{/*操作失利*/$links[]=array('text'=>$_LANG['order_info'],'href'=>'order.php?act=info&order_id='.$order_id);sys_msg($_LANG['act_false'],1,$links);}unset($filter_fileds,$delivery,$_delivery,$order_finish);/*定单信息更新处理*/if(true){/*符号订单为已承认“发货中”*//*更新发货时刻*/$order_finish=get_order_finish($order_id);$shipping_status=SS_SHIPPED_ING;if($order['order_status']!=OS_CONFIRMED&&$order['order_status']!=OS_SPLITED&&$order['order_status']!=OS_SPLITING_PART){$arr['order_status']=OS_CONFIRMED;$arr['confirm_time']=GMTIME_UTC;}$arr['order_status']=$order_finish?OS_SPLITED:OS_SPLITING_PART;//悉数分单、部分分单$arr['shipping_status']=$shipping_status;update_order($order_id,$arr);}/*记载log*/order_action($order['order_sn'],$arr['order_status'],$shipping_status,$order['pay_status'],$action_note);/*铲除缓存*/clear_cache_files();/*依据发货单id查询发货单信息*/if(!empty($delivery_id)){$delivery_order=delivery_order_info($delivery_id);}elseif(!empty($order_sn)){$delivery_id=$GLOBALS['db']->getOne("SELECTdelivery_idFROM".$ecs->table('delivery_order')."WHEREorder_sn=".$order_sn);$delivery_order=delivery_order_info($delivery_id);}else{die('orderdoesnotexist');}/*假如管理员归于某个办事处,查看该订单是否也归于这个办事处*/$sql="SELECTagency_idFROM".$ecs->table('admin_user')."WHEREuser_id='".$_SESSION['admin_id']."'";$agency_id=$db->getOne($sql);if($agency_id>0){if($delivery_order['agency_id']!=$agency_id){sys_msg($_LANG['priv_error']);}/*取当时办事处信息*/$sql="SELECTagency_nameFROM".$ecs->table('agency')."WHEREagency_id='$agency_id'LIMIT0,1";$agency_name=$db->getOne($sql);$delivery_order['agency_name']=$agency_name;}/*获得用户名*/if($delivery_order['user_id']>0){$user=user_info($delivery_order['user_id']);if(!empty($user)){$delivery_order['user_name']=$user['user_name'];}}/*获得区域名*/$sql="SELECTconcat(IFNULL(c.region_name,''),'',IFNULL(p.region_name,''),"."'',IFNULL(t.region_name,''),'',IFNULL(d.region_name,''))ASregion"."FROM".$ecs->table('order_info')."ASo"."LEFTJOIN".$ecs->table('region')."AScONo.country=c.region_id"."LEFTJOIN".$ecs->table('region')."ASpONo.province=p.region_id"."LEFTJOIN".$ecs->table('region')."AStONo.city=t.region_id"."LEFTJOIN".$ecs->table('region')."ASdONo.district=d.region_id"."WHEREo.order_id='".$delivery_order['order_id']."'";$delivery_order['region']=$db->getOne($sql);/*是否保价*/$order['insure_yn']=empty($order['insure_fee'])?0:1;/*获得发货单产品*/$goods_sql="SELECT*FROM".$ecs->table('delivery_goods')."WHEREdelivery_id=".$delivery_order['delivery_id'];$goods_list=$GLOBALS['db']->getAll($goods_sql);/*是否存在实体产品*/$exist_real_goods=0;if($goods_list){foreach($goods_listas$value){if($value['is_real']){$exist_real_goods++;}}}/*获得订单操作记载*/$act_list=array();$sql="SELECT*FROM".$ecs->table('order_action')."WHEREorder_id='".$delivery_order['order_id']."'ANDaction_place=1ORDERBYlog_timeDESC,action_idDESC";$res=$db->query($sql);while($row=$db->fetchRow($res)){$row['order_status']=$_LANG['os'][$row['order_status']];$row['pay_status']=$_LANG['ps'][$row['pay_status']];$row['shipping_status']=($row['shipping_status']==SS_SHIPPED_ING)?$_LANG['ss_admin'][SS_SHIPPED_ING]:$_LANG['ss'][$row['shipping_status']];$row['action_time']=local_date($_CFG['time_format'],$row['log_time']);$act_list[]=$row;}/*同步发货*//*判别付出方法是否付出宝*/$alipay=false;$order=order_info($delivery_order['order_id']);//依据订单ID查询订单信息,回来数组$order$payment=payment_info($order['pay_id']);//获得付出方法信息/*界说当时时刻*/define('GMTIME_UTC',gmtime());//获取UTC时刻戳/*依据发货单id查询发货单信息*/if(!empty($delivery_id)){$delivery_order=delivery_order_info($delivery_id);}else{die('orderdoesnotexist');}/*查询订单信息*/$order=order_info($order_id);/*查看此单发货产品库存缺货状况*/$virtual_goods=array();$delivery_stock_sql="SELECTDG.goods_id,DG.is_real,DG.product_id,SUM(DG.send_number)ASsums,IF(DG.product_id>0,P.product_number,G.goods_number)ASstorage,G.goods_name,DG.send_numberFROM".$GLOBALS['ecs']->table('delivery_goods')."ASDG,".$GLOBALS['ecs']->table('goods')."ASG,".$GLOBALS['ecs']->table('products')."ASPWHEREDG.goods_id=G.goods_idANDDG.delivery_id='$delivery_id'ANDDG.product_id=P.product_idGROUPBYDG.product_id";$delivery_stock_result=$GLOBALS['db']->getAll($delivery_stock_sql);/*假如产品存在标准就查询标准,假如不存在标准按产品库存查询*/if(!empty($delivery_stock_result)){foreach($delivery_stock_resultas$value){if(($value['sums']>$value['storage']||$value['storage']<=0)&&(($_CFG['use_storage']=='1'&&$_CFG['stock_dec_time']==SDT_SHIP)||($_CFG['use_storage']=='0'&&$value['is_real']==0))){/*操作失利*/$links[]=array('text'=>$_LANG['order_info'],'href'=>'order.php?act=delivery_info&delivery_id='.$delivery_id);sys_msg(sprintf($_LANG['act_good_vacancy'],$value['goods_name']),1,$links);break;}/*虚拟产品列表virtual_card*/if($value['is_real']==0){$virtual_goods[]=array('goods_id'=>$value['goods_id'],'goods_name'=>$value['goods_name'],'num'=>$value['send_number']);}}}else{$delivery_stock_sql="SELECTDG.goods_id,DG.is_real,SUM(DG.send_number)ASsums,G.goods_number,G.goods_name,DG.send_numberFROM".$GLOBALS['ecs']->table('delivery_goods')."ASDG,".$GLOBALS['ecs']->table('goods')."ASGWHEREDG.goods_id=G.goods_idANDDG.delivery_id='$delivery_id'GROUPBYDG.goods_id";$delivery_stock_result=$GLOBALS['db']->getAll($delivery_stock_sql);foreach($delivery_stock_resultas$value){if(($value['sums']>$value['goods_number']||$value['goods_number']<=0)&&(($_CFG['use_storage']=='1'&&$_CFG['stock_dec_time']==SDT_SHIP)||($_CFG['use_storage']=='0'&&$value['is_real']==0))){/*操作失利*/$links[]=array('text'=>$_LANG['order_i
声明:有的资源均来自网络转载,版权归原作者所有,如有侵犯到您的权益 请联系邮箱:123456@qq.com 我们将配合处理!
原文地址:Ecshop二次开发后台订单实现一键发货功能教程发布于2022-05-24 07:43:19