一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

ecshop增加手机号码归属地功能

时间:2022-06-25 16:30:05 编辑:袖梨 来源:一聚教程网

接口地址:http://tcc.taob*a**o.com/cc/json/mobile_tel_segment.htm?tel=手机号码,返回JSON。

手机号码归属地

一、编辑/includes/lib_common.php,添加归属地查询函数

代码如下 复制代码

/**
* 获取手机号码归属地和运营
*
* @param string $mobile 手机号码
* @return array
*/
function get_mobile_area($mobile)
{
$result = array('province'=>'', 'catName'=>''); //province-归属地 catName-运营商

$url = 'http://tcc.*ta*o*bao.com/cc/json/mobile_tel_segment.htm?tel=' . $mobile . '&t=' . time(); //淘宝API

$content = file_get_contents($url);
$content = iconv('GB2312', 'UTF-8', $content);

if(strlen($content) {
return;
}
else
{
$result['province'] = substr($content, "56", "6");
$result['catName'] = substr($content, "85", "6");
}

return $result;
}

二、编辑/admin/order.php,添加函数调用(高亮部分)

代码如下 复制代码

/* 格式化金额 */
if ($order['order_amount'] {
$order['money_refund'] = abs($order['order_amount']);
$order['formated_money_refund'] = price_format(abs($order['order_amount']));
}

/* 手机号码归属地 */
if (!empty($order['mobile']))
{
$result = get_mobile_area($order['mobile']);
$order['mobile_area'] = $result['province'] . $result['catName'];
}

三,编辑/admin/tempaltes/order_info.htm,在订单收货人信息中添加手机号码归属地






代码如下 复制代码

{$lang.label_tel}
{$order.tel}
{$lang.label_mobile}
{$order.mobile|escape} {$order.mobile_area}

热门栏目