使用前准备:
1.去 http://www.kdniao.com 注册账户 然后开通快递查询功能 免费的把获得的key和用户ID写到后台的插件中即可开始使用。
2.后台添加快递公司,需要下载对照表 把名称和编码写正确,编码注意都是大写。快递公司不建议设置过多设置我们常用的即可。
懒人包下载地址:[https://x1.php168.com/bbs/show-6540.html]()
一.核心修改文件
application\common\controller\member\KehuOrder.php
我们搜索:
```
$this->model->update($array)
```
在他的上面加上一句:
```
$array['shipping_name'] = $data['shipping_name'];
```
至此核心文件修改完毕。
二.模板修改文件 以自带shop为例,基于这个为原型的都可以这么改:
文件一:template\member_style\default\shop\kehu_order\edit.htm
我们只需要把:
```
<dl>
<dt>序列号:</dt>
<dd><input type="text" name="shipping_code" size="50" value="{$info.shipping_code}">序列号/注册码/物流单号</dd>
</dl>
```
修改为下面的即可:
```
<dl>
<dt>发货:</dt>
<dd>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="FormTable">
<tr>
<td class="tdL">快递公司:</td>
<td class="tdR"><select name="shipping_name">
{volist name=":fun('kuaidi@ajax')" id="vo"}
<option value="{$vo.bianhao}" {if condition="$info.shipping_name==$vo.bianhao" } selected="selected" {/if}>{$vo.name}</option>
{/volist}
</select></td>
</tr>
<tr>
<td class="tdL">快递单号:</td>
<td class="tdR"><input type="text" name="shipping_code" size="50" value="{$info.shipping_code}"></td>
</tr>
</table>
</dd>
</dl>
```
文件二:template\member_style\default\shop\kehu_order\pc_show.htm
文件三:template\member_style\default\shop\order\pc_show.htm
把:
```
<tr>
<td class="tdL">单号:</td>
<td class="tdR">{$info.shipping_name}{$info.shipping_code}</td>
</tr>
```
修改为:
```
<tr>
<td class="tdL">快递号:</td>
<td class="tdR">{$info.shipping_code} <a class="tag_org kuaiducha" data-id="{$info.shipping_name}-{$info.shipping_code}" style="cursor:pointer;">查看快递</a></td>
</tr>
```
然后在页面最底部 {/block} 上面加上:
```
<script type="text/javascript">
$('.kuaiducha').on('click', function() {
var id = '' + $(this).attr("data-id");
layer.open({
type: 2,
title: '查询快递',
area: ['800px', '500px'],
fixed: false, //不固定
shadeClose: true,
shade: 0.5,
content: "{:purl('kuaidi/kuaidi/ajax','','index')}?id=" + id
});
});
</script>
```
文件四:template\member_style\default\shop\kehu_order\show.htm
文件五:template\member_style\default\shop\order\show.htm
只需要把:
```
<ul class="infos">
<ol>订单号:</ol>
<li>{$info.order_sn}</li>
</ul>
```
改为下面的即可:
```
<ul class="infos">
<ol>快递号:</ol>
<li>{$info.shipping_code} <a href="{:purl('kuaidi/kuaidi/ajax','','index')}?id={$info.shipping_name}-{$info.shipping_code}" >查询快递</a></li>
</ul>
```
商城模块后台发货教程:
template\admin_style\default\shop 目录下我们新建一个order文件夹 里面创建一个edit.htm(UTF-8编码)
最终我们的目录就是:template\admin_style\default\shop\order\edit.htm
里面的内容如下:
```
{extend name="admin@index:layout" /}
{block name="content"}
<style type="text/css">
.layui-input-inline .layui-input{
width:500px;
}
</style>
<div class="MainContainers">
<form name="" method="post" action="{php}echo preg_replace('/(http|https):\/\/([^\/]+)\/(.*)/i','/\\3',get_url('location'));/*解决有的服务器无法识别https*/{/php}" class="ajax_post {notempty name='$tab_ext.trigger'} form-trigger {else /} layui-form {/notempty}">
<div class="Header"><span class="tag">{if ($tab_ext['page_title'])} {$tab_ext.page_title} {elseif (empty($info))}添加{else /}修改{/if}</span> </div>
<div class="Conter">
<!-- 功能接口钩子 -->
{:hook_listen('template_form_head',$f_array,$info,true)}
<table class="FormTable">
<!-- 参数 field="pic,tit" 代表过滤哪些字段不显示出来 里边支持TP标签 -->
{qb:form field="" f_array="$f_array"}
<tr id="form_group_{$rs.name}">
<td class='tdL'>{$rs.title}: </td>
<td class="tdR {if in_array($rs['type'],['text','password','number','select'])}layui-input-inline{else /}layui-input-block{/if}"><div>{$rs.value}</div>
{notempty name="$rs.about"}
<div class="layui-form-mid layui-word-aux">{$rs.about}</div>
{/notempty} </td>
</tr>
{/qb:form}
<tr id="form_group_shipping_name">
<td class='tdL'>快递公司: </td>
<td class="tdR layui-input-inline"><div>
<select name="shipping_name">
{volist name=":fun('kuaidi@ajax')" id="vo"}
<option value="{$vo.bianhao}" {if condition="$info.shipping_name==$vo.bianhao" } selected="selected" {/if}>{$vo.name}</option>
{/volist}
</select>
</div></td>
</tr>
</table>
<!-- 功能接口钩子 -->
{:hook_listen('template_form_foot',$f_array,$info,true)}
<div class='submits'> {notempty name=":input('id')"}
<input type="hidden" name="id" value="{:input('id')}">
{/notempty}
{if $tab_ext.hidebtn!='back'}
<input type="button" onclick="window.history.back()" style="color:#555;margin-right:30px;" onmouseout="$(this).css({'background':'#eee'})" onmouseover="$(this).css({'background':'orange'})" value="取消返回">
{/if}
{$tab_ext.addbtn}
<input type="submit" name="Submit" value="确认提交">
</div>
</div>
</form>
</div>
<!-- 表单常用事件,比如无刷新提交 -->
<script LANGUAGE="JavaScript" src="__STATIC__/js/form/base.js"></script>
{/block}
```