Skip to content

anvari182/laravel-tracking-more

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel TrackingMore

A Laravel package for managing TrackingMore API.

TrackingMore helps eCommerce businesses to update and manage their shipment with efficiency.

This package is a wrapper of TrackingMore API PHP SDK for Laravel.

Version support

  • PHP: 8.0 | 8.1 | 8.2
  • Laravel: 10.0

Installation

You can install using composer from Packagist.

$ composer require anvari182/laravel-tracking-more

Configuration

Add TRACKING_MORE_API_KEY in your .env file.

Get your TrackingMore API key from TrackingMore

php artisan vendor:publish --provider="Anvari182\TrackingMore\TrackingMoreServiceProvider" --tag="config"

Usage

Inject the Tracking or Courier where you need:

use Anvari182\TrackingMore\TrackingMoreRequests\Tracking;
use Anvari182\TrackingMore\TrackingMoreRequests\Courier;
use Anvari182\TrackingMore\Data\TrackingData;

public function __construct(private Tracking $tracking, private Courier $courier)
{
}

public function index()
{
   // Create a tracking
   $this->tracking->createTracking(['tracking_number' => 'xyz123', 'courier_code' => 'ups']);
   
   // Get all couriers
   $couriers = $this->courier->getAllCouriers();
}

Or use it with Facade:

use Anvari182\TrackingMore\Facades\TrackingMore;

// Create a tracking
TrackingMore::tracking()->createTracking(['tracking_number' => 'xyz123', 'courier_code' => 'ups'])

 // Get all couriers
$couriers = TrackingMore::courier()->getAllCouriers();

Tracking

Create a tracking
TrackingMore::tracking()->createTracking(['tracking_number' => 'xyz123', 'courier_code' => 'ups'])
Get results
TrackingMore::tracking()->getTrackingResults()
Create trackings

Create multiple trackings (Max. 40 tracking numbers create in one call).

 TrackingMore::tracking()->batchCreateTrackings([
        ['tracking_number' => 'xyz1234', 'courier_code' => 'ups'],
        ['tracking_number' => 'xyz1235', 'courier_code' => 'ups'],
        ['tracking_number' => 'xyz1236', 'courier_code' => 'ups'],
    ]);
Update a tracking by ID

Tracking ID

TrackingMore::tracking()->updateTrackingByID('13123213213213', ['note' => 'New test order note', 'customer_name'=>'New name'])
Delete a tracking by ID

Tracking ID

TrackingMore::tracking()->deleteTrackingByID('13123213213213')
Retrack an expired tracking by ID

Tracking ID

TrackingMore::tracking()->retrackTrackingByID('13123213213213')

Courier

Detect courier

Return a list of matched couriers based on submitted tracking number.

TrackingMore::courier()->detect(['tracking_number' => '9261290312833844954982'])
Get all couriers

Return a list of all supported couriers.

TrackingMore::courier()->getAllCouriers()

Dependencies

TrackingMore API PHP SDK v.1.0.0

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This project is licensed under the MIT License - see the LICENSE file for details.