PHP code example of piteurstudio / courierdz

1. Go to this page and download the library: Download piteurstudio/courierdz 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/ */

    

piteurstudio / courierdz example snippets



// Ecotrack providers
$credentials = ['token' => '****'];

// Procolis providers ( ZREXPRESS )
$credentials = ['id' => '****', 'token' => '****'];

// Yalidine providers
$credentials = ['token' => '****', 'key' => '****'];

// Mayestro Delivery providers
$credentials = ['token' => '****'];


$shipping_provider = CourierDZ::provider(ShippingProvider::ZREXPRESS, $credentials);

// or 

$shipping_provider = new XyzProvider($credentials); // where Xyz is the provider name

/*
 * return array of provider response
 * Note : results may vary depending on the provider
 */
 
$result = $shipping_provider->createOrder([
        'Tracking' => 'CourierDz-123',
        'TypeLivraison' => 1,
        'TypeColis' => 0,
        'Confrimee' => 0,
        'Client' => 'Mohamed',
        'MobileA' => '0990909090',
        'MobileB' => '0880808080',
        'Adresse' => 'Rue 39',
        'IDWilaya' => "09",
        'Commune' => 'Maraval',
        'Total' => "2000",
        'Note' => 'test test',
        'TProduit' => 'Article1',
        "id_Externe" => 'CourierDz-123',
        "Source" => 'CourierDz',
    ]))

$rules = $shipping_provider->getCreateOrderValidationRules();

/*
 * return array of label data ( base64 encoded string or url )
 */
 
$label = $shipping_provider->orderLabel('CourierDz-123');