hjkhghtjhjjhjhjhjhjjhjhjjhrrtrtoirh
bnmbertsurrttrtrtrtrjhjhjjhjhhjhjhjhf'tdfg
/
home
/
u506006416
/
domains
/
crystalmiracle.co.in
/
public_html
/
admin
/
include
/
Upload FileeE
HOME
<?php include_once('shiprocket.php'); class ExpressBess_config{ public $shipRocket; public $shipmentToken; public $emailIdExpree = 'sales.crystalmiracle@gmail.com'; public $passwordExpree = 'xpressbeesindia123'; public function __construct() { $this->shipRocket = new shiprocket_config(); $this->shipmentToken = $this->GetExpressBessShipmentToken($this->emailIdExpree,$this->passwordExpree); } public function GetExpressBessShipmentToken($loginEmailID,$loginPassword){ $Header = json_encode(array('email'=>$loginEmailID,'password'=>$loginPassword)); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://shipment.xpressbees.com/api/users/login', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>$Header, CURLOPT_HTTPHEADER => array( 'Content-Type: text/plain', 'Cookie: ci_session=0q5tgo7m8e8c7bsmkqstn4ujfrc6qn3i' ), )); $response = curl_exec($curl); curl_close($curl); return json_decode($response)->data; } private function ExpressBessShippingtoken(){ $token = $this->shipmentToken; return $token; } public function ShippingCarrerName(){ $token = $this->base_64_token; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://app.shipway.com/api/getcarrier', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( "Authorization: Basic $token" ), )); $response = curl_exec($curl); echo "<pre>"; print_r(json_decode($response));die; } public function ExpressOrderPunch($orderID){ $orderData = $this->getOrderDetailsForExpressBess($orderID); $token = $this->ExpressBessShippingtoken(); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://shipment.xpressbees.com/api/shipments2', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( "Authorization: Basic $token", "Content-Type: Application/JSON", "Cookie: ci_session=v9outjfr7n7v758ooq6ap86e4s0s2d0h" ), CURLOPT_POSTFIELDS =>$orderData, )); $response = curl_exec($curl); $response = json_decode($response); curl_close($curl); if($response->status==true){ $response_data = $response->data; $awb_number = $response_data->awb_number; $label = $response_data->label; $manifest = $response_data->manifest; $shipId = $response_data->shipment_id; $status="Success"; $msg="Order Placed Successfully"; $update_order = array('assign_to'=>'XpressBees','shiprocketODR_id'=>$awb_number, 'order_status'=>'Processed','minfist'=>$manifest,'shipment_id'=>$shipId,'label'=>$label); $order_where_condition = array('order_id'=>$orderID); $this->shipRocket->update_orders("orders",$update_order,$order_where_condition); }else{ print_r("<h4>".$response->message."</h4>"); echo " <h4><a href='all_orders.php'>Back</a><h4>"; die; } } public function get_order_details_by_id($orderID){ return $this->shipRocket->order_by_orderID($orderID); } private function getOrderDetailsForExpressBess($orderID = ''){ $item_list = []; $get_order = $this->get_order_details_by_id($orderID); $all_item = $this->shipRocket->item_list_in_order($get_order['id']); foreach($all_item as $item){ $condition1="`p_id`=".$item['p_id']; $p_query = $this->shipRocket->displayRecodsAl('product',$condition1); if(is_array($p_query) || !empty($p_query)) { foreach($p_query as $p_data) { } } if($p_data['p_name'] !='' && $p_data['price']!=''){ $item_list[] = array( "name" => str_replace('"','',$p_data['p_name']), "price" => $p_data['price'], "sku" => $p_data['p_code'], "qty" => $item['quantity'] ); } } if ($get_order['pay_type']==1) { $collectable_amount = $get_order['t_price']; $payment_method = 'cod'; }elseif ($get_order['pay_type']==2) { $collectable_amount = 0; $payment_method = 'prepaid'; }else{ $payment_method = 'cod';$collectable_amount = $get_order['t_price']; } /*--------- Weight -----*/ if ($get_order['weight']<=0) { $weight = 0.100; }else{ $weight = $get_order['weight']; } /*--------- length -----*/ if ($get_order['length']<=0) { $length = 10; }else{ $length = $get_order['length']; } /*--------- breadth -----*/ if ($get_order['breadth']<=0) { $breadth = 8; }else{ $breadth = $get_order['breadth']; } /*--------- height -----*/ if ($get_order['height']<=0) { $height = 2; }else{ $height = $get_order['height']; } /*----------------------*/ $orderDetails = array( "order_number" => $orderID, "unique_order_number" => "yes", "shipping_charges" => $get_order['shipping_price'], "discount" => $get_order['shipping_price'], "cod_charges" => 0, "payment_type" => $payment_method, "order_amount" => $get_order['t_price'], "package_weight" => $weight*1000, "package_length" => $length, "package_breadth" => $breadth, "package_height" => $height, "request_auto_pickup" => "yes", "consignee" => array( "name" => $get_order['f_name']." ". $get_order['l_name'], "address" => $get_order['str_address1'], "address_2"=> $get_order['str_address2'], "city" => $get_order['town'], "state" => $get_order['state'], "pincode" => $get_order['pincode'], "phone" => $get_order['p_no'] ), "pickup" => array( "warehouse_name" => "Crystal Miracle", "name" => "Ekta", "address" => "G-1, Third Floor, Lajpat Nagar - 2", "address_2" => "New Delhi", "city" => "DELHI NCR", "state" => "Delhi", "pincode" => "110024", "phone" => "9718042500" ), "order_items" =>(object)$item_list, "courier_id" => 1, "collectable_amount" => $collectable_amount ); return json_encode($orderDetails); } function cancel_order_Express($awbNumber){ $token = $this->ExpressBessShippingtoken(); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://shipment.xpressbees.com/api/shipments2/cancel', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>json_encode(array('awb'=>$awbNumber)), CURLOPT_HTTPHEADER => array( "Authorization: Basic $token", "Content-Type: Application/JSON", "Cookie: ci_session=v9outjfr7n7v758ooq6ap86e4s0s2d0h" ) )); $response = curl_exec($curl); curl_close($curl); } function Manifest_Download_Express($awbNumber){ $token = $this->ExpressBessShippingtoken(); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://shipment.xpressbees.com/api/shipments2/manifest', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>json_encode(array('awbs'=>array($awbNumber))), CURLOPT_HTTPHEADER => array( "Authorization: Basic $token", "Content-Type: Application/JSON", "Cookie: ci_session=v9outjfr7n7v758ooq6ap86e4s0s2d0h" ) )); $response = curl_exec($curl); print_r($response);die; curl_close($curl); } }