PHP code example of ivanmitrikeski / laravel-shipping
1. Go to this page and download the library: Download ivanmitrikeski/laravel-shipping 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/ */
ivanmitrikeski / laravel-shipping example snippets
$exceptions = [];
$rates = app(\Mitrik\Shipping\Facades\Shipping::class)->rates(
new Address(
'Ivan',
'Mitrikeski',
'',
'321 Lakeshore Rd W',
'',
'Mississauga',
'L5H 1G0',
'ON',
'CA'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'100 City Centre Dr',
'',
'Mississauga',
'L5B 2C9',
'ON',
'CA'
),
new \Mitrik\Shipping\ServiceProviders\Box\BoxCollection([
new BoxMetric(20, 10, 5, 1)
]),
$exceptions
);
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceCanadaPost\ServiceCanadaPost;
use Mitrik\Shipping\ServiceProviders\ServiceCanadaPost\ServiceCanadaPostCredentials;
$credentials = new ServiceCanadaPostCredentials(env('CANADA_POST_CUSTOMER_NUMBER'), env('CANADA_POST_USERNAME'), env('CANADA_POST_PASSWORD'));
$canadaPost = new ServiceCanadaPost($credentials);
$rates = $canadaPost->rate(
new Address(
'Ivan',
'Mitrikeski',
'',
'321 Lakeshore Rd W',
'',
'Mississauga',
'L5H 1G0',
'ON',
'CA'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'100 City Centre Dr',
'',
'Mississauga',
'L5B 2C9',
'ON',
'CA'
),
new BoxCollection([
new BoxMetric(20, 10, 5, 1)
])
);
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServicePurolator\ServicePurolator;
use Mitrik\Shipping\ServiceProviders\ServicePurolator\ServicePurolatorCredentials;
$credentials = new ServicePurolatorCredentials(env('PUROLATOR_KEY'), env('PUROLATOR_PASSWORD'), env('PUROLATOR_BILLING_ACCOUNT'), env('PUROLATOR_REGISTERED_ACCOUNT'), env('PUROLATOR_USER_TOKEN'), env('PUROLATOR_SANDBOX'));
$purolator = new ServicePurolator($credentials);
$rates = $purolator->rate(
new Address(
'Ivan',
'Mitrikeski',
'',
'321 Lakeshore Rd W',
'',
'Mississauga',
'L5H 1G0',
'ON',
'CA'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'100 City Centre Dr',
'',
'Mississauga',
'L5B 2C9',
'ON',
'CA'
),
new BoxCollection([
new BoxMetric(20, 10, 5, 1)
])
);
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceUPS\ServiceUPS;
use Mitrik\Shipping\ServiceProviders\ServiceUPS\ServiceUPSCredentials;
$credentials = new ServiceUPSCredentials(env('UPS_ACCESS_KEY'), env('UPS_USER_ID'), env('UPS_PASSWORD'));
$serviceUPS = new ServiceUPS($credentials);
$rates = $serviceUPS->rate(
new Address(
'Ivan',
'Mitrikeski',
'',
'321 Lakeshore Rd W',
'',
'Mississauga',
'L5H 1G0',
'ON',
'CA'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'100 City Centre Dr',
'',
'Mississauga',
'L5B 2C9',
'ON',
'CA'
),
new BoxCollection([
new BoxMetric(20, 10, 5, 1)
])
);
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceUSPS\ServiceUSPS;
use Mitrik\Shipping\ServiceProviders\ServiceUSPS\ServiceUSPSCredentials;
$credentials = new ServiceUSPSCredentials(env('USPS_USERNAME'), env('USPS_PASSWORD'));
$usps = new ServiceUSPS($credentials);
$rates = $usps->rate(
new Address(
'Ivan',
'Mitrikeski',
'',
'1 Wall St',
'',
'New York',
'10005',
'NY',
'US'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'1 Wall St',
'',
'New York',
'10005',
'NY',
'US'
),
new BoxCollection([
new BoxMetric(20, 10, 5, 1)
])
);
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceFedEx\ServiceFedEx;
use Mitrik\Shipping\ServiceProviders\ServiceFedEx\ServiceFedExCredentials;
$credentials = new ServiceFedExCredentials(env('FEDEX_CLIENT_ID'), env('FEDEX_CLIENT_SECRET'), env('FEDEX_ACCOUNT_NUMBER'));
$fedEx = new ServiceFedEx($credentials);
$rates = $fedEx->rate(
new Address(
'Ivan',
'Mitrikeski',
'',
'1 Wall St',
'',
'New York',
'10005',
'NY',
'US'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'1 Wall St',
'',
'New York',
'10005',
'NY',
'US'
),
new BoxCollection([
new BoxMetric(20, 10, 5, 1)
])
);
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceFlat\ServiceFlat;
$flat = new ServiceFlat();
$rates = $flat->rate(
new Address(
'Ivan',
'Mitrikeski',
'',
'321 Lakeshore Rd W',
'',
'Mississauga',
'L5H 1G0',
'ON',
'CA'
),
new Address(
'Ivan',
'Mitrikeski',
'',
'100 City Centre Dr',
'',
'Mississauga',
'L5B 2C9',
'ON',
'CA'
),
new BoxCollection([
new BoxMetric(35, 26, 5, 1)
])
);