PHP code example of quellabs / canvas-shipments

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

    

quellabs / canvas-shipments example snippets


use Quellabs\Shipments\ShipmentRouter;
use Quellabs\Shipments\Contracts\ShipmentRequest;
use Quellabs\Shipments\Contracts\ShipmentAddress;
use Quellabs\Shipments\Contracts\CancelRequest;

class FulfillmentService {
    public function __construct(private ShipmentRouter $router) {}

    public function ship(): ShipmentResult {
        return $this->router->create(new ShipmentRequest(
            shippingModule:  'sendcloud_postnl',
            reference:       'order-12345',
            deliveryAddress: new ShipmentAddress(
                name:              'Jan de Vries',
                street:            'Keizersgracht',
                houseNumber:       '123',
                houseNumberSuffix: null,
                postalCode:        '1015 CJ',
                city:              'Amsterdam',
                country:           'NL',
                email:             '[email protected]',
            ),
            weightGrams: 1200,
            methodId:    8,
        ));
    }
}
json
"extra": {
"discover": {
"canvas": {
"controller": "Quellabs\\Shipments\\SendCloud\\SendCloudController"
},
"shipments": {
"provider": "Quellabs\\Shipments\\SendCloud\\Driver",
"config": "config/sendcloud.php"
}
}
}