PHP code example of dhl / module-unified-tracking

1. Go to this page and download the library: Download dhl/module-unified-tracking 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/ */

    

dhl / module-unified-tracking example snippets


// \Vendor\Module\Model\Carrier::getTrackingInfo

public function getTrackingInfo($tracking)
{
    $result = $this->trackingInfoProvider->getTrackingDetails($tracking, $this->getCarrierCode());
    
    if ($result instanceof \Magento\Shipping\Model\Tracking\Result\Error) {
        // create link to portal if web service returned an error
        $statusData = [
            'tracking' => $tracking,
            'url' => 'https://trackntrace.carrier.com/?track=' . $tracking,
        ];
        $result = $this->_trackStatusFactory->create(['data' => $statusData]);
    }

    return $result;
}
xml
<type name="Vendor\Module\Model\Carrier">
    <plugin name="dhlgw_get_tracking_info" type="Dhl\UnifiedTracking\Plugin\Carrier\GetTrackingDetails"/>
</type>