Skip to content

Instantly share code, notes, and snippets.

@rmak78
Created November 27, 2021 10:42
Show Gist options
  • Save rmak78/ed29ae66b960d025a5be627a5851b1e7 to your computer and use it in GitHub Desktop.
Save rmak78/ed29ae66b960d025a5be627a5851b1e7 to your computer and use it in GitHub Desktop.
<?php
require('../functions.php');
$order_id = isset($_POST['order_id'])?(int)$_POST['order_id']:die('Whoops..! Something went wrong');
$order = DB::queryFirstRow("SELECT * FROM oc_order o
WHERE o.`order_id` = '".$order_id."'");
$weight = $_POST['weight'];
$pieces = $_POST['pieces'];
$collec_amount = $_POST['collect_amount'];
$city = $_POST['city'];
$shipment_type = $_POST['shipment_type'];
$instructions = $_POST['instructions'];
$data = array(
'api_key' => LCS_API_KEY,
'api_password' => LCS_API_PASSWORD,
'booked_packet_weight' => $weight, // Weight should in 'Grams' e.g. '2000'
'booked_packet_no_piece' => $pieces, // No. of Pieces should an Integer Value
'booked_packet_collect_amount' => $collec_amount, // Collection Amount on Delivery
'booked_packet_order_id' => $order_id, // Optional Filed, (If any) Order ID of Given Product
'origin_city' => 99, /** Params: 'self' or 'integer_value' e.g. 'origin_city' => 'self' or 'origin_city' => 789 (where 789 is Lahore ID)
* If 'self' is used then Your City ID will be used.
* 'integer_value' provide integer value (for integer values read 'Get All Cities' api documentation)
*/
'destination_city' => $city, /** Params: 'self' or 'integer_value' e.g. 'destination_city' => 'self' or 'destination_city' => 789 (where 789 is Lahore ID)
* If 'self' is used then Your City ID will be used.
* 'integer_value' provide integer value (for integer values read 'Get All Cities' api documentation)
*/
'shipment_name_eng' => 'self', // Params: 'self' or 'Type any other Name here', If 'self' will used then Your Company's Name will be Used here
'shipment_email' => 'self', // Params: 'self' or 'Type any other Email here', If 'self' will used then Your Company's Email will be Used here
'shipment_phone' => 'self', // Params: 'self' or 'Type any other Phone Number here', If 'self' will used then Your Company's Phone Number will be Used here
'shipment_address' => 'self', // Params: 'self' or 'Type any other Address here', If 'self' will used then Your Company's Address will be Used here
'consignment_name_eng' => $order['shipping_firstname']." ".$order['shipping_lastname'], // Type Consignee Name here
'consignment_email' => $order['email'], // Optional Field (You can keep it empty), Type Consignee Email here
'consignment_phone' => $order['telephone'], // Type Consignee Phone Number here
'consignment_address' => $order['shipping_address_1']." ".$order['shipping_address_2'], // Type Consignee Address here
'special_instructions' => " CALL CLIENT BEFORE DELIVERY ATTEMPT | FRAGILE | HANDLE WITH CARE | DONOT OPEN WITHOUT PAYMENT | Please Call/Whatsapp 0313-3359999 before return to origin incase of failed delivery | ".$instructions , // Type any instruction here regarding booked packet
'shipment_type' => 'string', // Optional Field (You can keep it empty so It will pick default value i.e. "overnight"), Type Shipment type name here
);
print_r($data);
$url = LCS_BOOK_PACKET_URL ;
$buffer = callAPI("POST",$url,$data);
// echo $buffer;
$response = json_decode( $buffer,true );
if($response['status'] == 1 && $response['error']==0){
{
/* "status" : 1,
"error" : 0,
"track_number" : "string"
"slip_link" : "string" // Copy this URL in Browser to Get Slip
*/
$update_tracking = DB::Query("UDPATE oc_order SET airway_bill ='".$response['track_number']."' , track_url='LEOPARD' WHERE order_id = ".$order_id );
echo '<h2><center><a href="'.$response['slip_link'].'" target="_blank" >'.$response['slip_link'].'</a></center></h2>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment