Inheritance: extends EasypostResource
 public function trackPackage($id)
 {
     $track = ShippingLabel::where('cart_id', $id)->first();
     $check = \EasyPost\Tracker::retrieve($track->easypost_tracking);
     if ($check->status == 'delivered') {
         Shipping::where('cart_id', $id)->update(['shipped_status' => 'DELIVERED', 'tracking_number' => $check->updated_at]);
         return redirect()->route('salesmanager.index');
     }
     Shipping::where('cart_id', $id)->update(['shipped_status' => 'SHIPPED', 'tracking_number' => $check->tracking_code]);
     return view('shipping.status', compact('check'));
 }
Beispiel #2
0
 public function get_tracking($track_code)
 {
     $est_date = $status = $signed_by = $update_at = '';
     $carrier = 'DHLExpress';
     $tracker = \EasyPost\Tracker::create(array('tracking_code' => $track_code, 'carrier' => $carrier));
     $tracker = $tracker->__toArray(true);
     if (!empty($tracker['est_delivery_date'])) {
         $est_date = $tracker['est_delivery_date'];
     }
     if (!empty($tracker['signed_by'])) {
         $signed_by = $tracker['signed_by'];
     }
     $status = $tracker['status'];
     $source = array('T', 'Z');
     $dest = array(' ', '');
     $update_at = str_replace($source, $dest, $tracker['updated_at']);
     $result = array('shp_estdate' => $est_date, 'shp_status' => $status, 'shp_updateat' => $update_at, 'shp_signedby' => $signed_by);
     $where = array('shp_trackingcode', $track_code);
     $this->update($result, $where);
     return $tracker['tracking_details'];
 }
Beispiel #3
0
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$tracking_code = "EZ2000000002";
$carrier = "USPS";
$tracker = \EasyPost\Tracker::create(array('tracking_code' => $tracking_code, 'carrier' => $carrier));
print_r($tracker);
$tracker2 = \EasyPost\Tracker::retrieve($tracker->id);
print_r($tracker2);
 /**
  * track a shipment
  *
  * @param string $trackingId
  * @return \EasyPost\Tracker
  * @throws \browner12\shipping\ShippingException
  */
 public function track($trackingId)
 {
     //try
     try {
         //retrieve tracker
         return $tracker = Tracker::retrieve($trackingId);
     } catch (EasyPostException $e) {
         //throw shipping exception
         throw new ShippingException('Unable to track shipment.', 0, $e);
     }
 }
Beispiel #5
0
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$tracking_code = "9611913638261560007008";
$tracker = \EasyPost\Tracker::create(array('tracking_code' => $tracking_code));
// $tracker = \EasyPost\Tracker::create(array('tracking_code' => $tracking_code, 'carrier' => 'fedexsmartpost'));
// $tracker = \EasyPost\Tracker::retrieve('trk_xxxxxxxx');
print_r($tracker);
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$trackers_rep = array();
for ($i = 0; $i < 5; $i++) {
    $tracker = array();
    $tracker["tracking_code"] = "EZ2000000002";
    $tracker["carrier"] = "USPS";
    array_push($trackers_rep, $tracker);
}
$trackers = \EasyPost\Tracker::create_list($trackers_rep);
var_dump($trackers);
Beispiel #7
0
$tracking_code = "EZ2000000002";
$carrier = "USPS";
// create test tracker
$tracker = \EasyPost\Tracker::create(array('tracking_code' => $tracking_code, 'carrier' => $carrier));
var_dump($tracker->id);
// This is random
// retrieve tracker by id
$tracker2 = \EasyPost\Tracker::retrieve($tracker->id);
var_dump($tracker2->id);
$params = array();
// Should be the same as above
// retrieve all trackers by tracking_code
$trackers = \EasyPost\Tracker::all(array('tracking_code' => $tracking_code));
var_dump(count($trackers["trackers"]));
// Should be 30
var_dump($trackers["has_more"]);
// Should be true, unless the count() isn't 30
var_dump($trackers["trackers"][0]->id);
// Should be the same as the ids above
// create another test tracker
$tracker3 = \EasyPost\Tracker::create(array('tracking_code' => $tracking_code, 'carrier' => $carrier));
var_dump($tracker3->id);
// This is random
// retrieve all created since 'tracker'
$trackers2 = \EasyPost\Tracker::all(array('after_id' => $tracker->id));
var_dump(count($trackers2["trackers"]));
// Should be 1
var_dump($trackers2["has_more"]);
// Should be false
var_dump($trackers2["trackers"][0]->id);
// Should be the same as the id for tracker3