Post by penguinq » Thu Jul 26, 2012 11:03 am

Hi I met a problem to integrate the Tracking API with opencart. The Tracking API works for hundreds of the chinese shipping carriers. It needs two variables, shipping company code and tracking number. I am not a php developer and don't know how to deal with this. Ideally, when a customer makes an order and the item is shipped, the store administrator should be able to add shipping company code and tracking number to the order. Could anyone help me with this that would be really appreciated.

Thanks.

Code: Select all

<?php
$typeCom = $_GET["com"];//Shipping Carriers
$typeNu = $_GET["nu"];  //Tracking Code

//echo $typeCom.'<br/>' ;
//echo $typeNu ;

$AppKey='XXXXXX';//Please replace XXXXXX with the key you got at http://kuaidi100.com/app/reg.html
$url ='http://api.kuaidi100.com/api?id='.$AppKey.'&com='.$typeCom.'&nu='.$typeNu.'&show=2&muti=1&order=asc';

//Dont' delete information of $powered.
$powered = 'Tracking Data is from:<a href="http://kuaidi100.com" target="_blank">KuaiDi100.Com</a>  ';


//curl mode is preferred to send data 
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->referer = 'http://www.google.com/';
  $snoopy->fetch($url);
  $get_content = $snoopy->results;
}
print_r($get_content . '<br/>' . $powered);
exit();
?>

Newbie

Posts

Joined
Thu Jul 26, 2012 10:48 am

Post by Avvici » Wed Aug 01, 2012 8:08 am

Smartest way is to add the tracking to the order when you change the order status from complete to shipped. It will take adding a field in the ORDER table for the tracking as well as code inside the control and the model file.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC
Who is online

Users browsing this forum: No registered users and 2 guests