PHP code example of tims / laravel-shiprocket

1. Go to this page and download the library: Download tims/laravel-shiprocket library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tims / laravel-shiprocket example snippets


Shiprocket::orders()->list(['page' => 1]);
Shiprocket::couriers()->serviceability([...]);
Shiprocket::withCredential('second')->warehouse()->srfServiceability([...]);

'default_credentials' => env('SHIPROCKET_DEFAULT_CREDENTIALS', 'default'),

'credentials' => [
    'default' => [
        'email' => env('SHIPROCKET_EMAIL'),
        'password' => env('SHIPROCKET_PASSWORD'),
    ],
    'second' => [
        'email' => env('SHIPROCKET_SECOND_EMAIL'),
        'password' => env('SHIPROCKET_SECOND_PASSWORD'),
    ],
],

Shiprocket::withCredential('second')->orders()->list();

use Tims\LaravelShiprocket\Facades\Shiprocket;

$rates = Shiprocket::couriers()->serviceability([
    'pickup_postcode' => '110030',
    'delivery_postcode' => '122001',
    'weight' => 0.5,
    'cod' => 0,
]);

$orders = Shiprocket::orders()->list(['page' => 1]);

$srf = Shiprocket::warehouse()->srfServiceability([
    'postcode' => '110030',
    'sku' => 'SKU-1',
    'quantity' => 1,
]);

use Tims\LaravelShiprocket\ShiprocketManager;

public function index(ShiprocketManager $shiprocket)
{
    return $shiprocket->orders()->list(['page' => 1]);
}

use Tims\Shiprocket\Api\OrdersApi;

$client = Shiprocket::client();
$api = Shiprocket::make(OrdersApi::class);
$token = Shiprocket::getToken();

use Tims\LaravelShiprocket\Facades\Shiprocket;

Shiprocket::forgetToken();
Shiprocket::withCredential('second')->forgetToken();
bash
php artisan vendor:publish --tag=shiprocket-config