分享一个快递跟踪插件,此插件遵循ecshop二次开发规则,未修改数据库,不影响系统升级,可以方便的卸载。申请快递100授权Key:http://www.kuaidi100.com,将文件上传到网站,覆盖前请先备份,修改/plugins/kuaidi100/kuaidi100_config.php,填写$kuaidi100key。
修改的部分本文均用高亮标示,ecshop2.7.2和2.7.3非默认模板可以参考高亮部分自行修改。
一、/plugins/kuaidi100/kuaidi100_config.php
<?php
//快递100查询接口专用Key,申请Key地址:http://www.kuaidi100.com/openapi/
$kuaidi100key = "xxxxxxxxxxxxxxxx";
/**
* 提示:如果您需要的公司不在以下列表,请按以下方法自行添加或修改,快递公司名称区分大小写。
* case与ecshop后台【系统设置】->【配送方式】中的快递名称一致。
* $postcom中的名称与【http://code.google.com/p/kuaidi-api/wiki/Open_API_API_URL】下的【快递公司代码】一致。
*/
switch ($getcom)
{
case "EMS": //ecshop后台中显示的快递名称
$postcom = 'ems'; //快递公司代码
break;
case "中国邮政":
$postcom = 'ems';
break;
case "申通快递":
$postcom = 'shentong';
break;
case "圆通速递":
$postcom = 'yuantong';
break;
case "顺丰速运":
$postcom = 'shunfeng';
break;
case "天天快递":
$postcom = 'tiantian';
break;
case "韵达快递":
$postcom = 'yunda';
break;
case "中通速递":
$postcom = 'zhongtong';
break;
case "龙邦物流":
$postcom = 'longbanwuliu';
break;
case "宅急送":
$postcom = 'zhaijisong';
break;
case "全一快递":
$postcom = 'quanyikuaidi';
break;
case "汇通速递":
$postcom = 'huitongkuaidi';
break;
case "民航快递":
$postcom = 'minghangkuaidi';
break;
case "亚风速递":
$postcom = 'yafengsudi';
break;
case "快捷速递":
$postcom = 'kuaijiesudi';
break;
case "华宇物流":
$postcom = 'tiandihuayu';
break;
case "中铁快运":
$postcom = 'zhongtiewuliu';
break;
case "FedEx":
$postcom = 'fedex';
break;
case "UPS":
$postcom = 'ups';
break;
case "DHL":
$postcom = 'dhl';
break;
default:
$postcom = '';
}
二、/plugins/kuaidi100/kuaidi100_post.php
<?php
$getcom = $_GET["com"];
$getNu = $_GET["nu"];
include_once("kuaidi100_config.php");
if(isset($postcom) && isset($getNu))
{
$url = 'http://www.kuaidi100.com/applyurl?key=' . $kuaidi100key . '&com=' . $postcom . '&nu=' . $getNu;
$powered = '查询服务由:<a href="http://www.kuaidi100.com/" target="_blank" style="color:blue">快递100</a> 网站提供';
//优先使用curl模式发送数据
if (function_exists('curl_init') == 1)
{
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_HEADER, 0);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt ($curl, CURLOPT_TIMEOUT, 5);
$get_content = curl_exec($curl);
curl_close ($curl);
}
else
{
include("snoopy.php");
$snoopy = new snoopy();
$snoopy->fetch($url);
$get_content = $snoopy->results;
}
echo '<iframe src="' . $get_content . '" width="534" height="340" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"><br/>' . $powered;
}
else
{
echo '查询失败,请重试';
}
exit();
?>
三、/plugins/kuaidi100/snoopy.php <————点击下载SNOOPY.php源码
四、/includes/lib_transaction.php <————点击下载lib_transaction.php源码
五、后台模板/admin/templates/order_info.htm <————点击下载order_info.htm源码
六、前台默认模板/themes/default/user_transaction.dwt <————点击下载user_transaction.dwt源码
前台效果
后台效果
新闻热点
疑难解答