-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from sektor-sumy/i-parcel
add i-parcel calculator
- Loading branch information
Showing
7 changed files
with
2,211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
use EsteIt\ShippingCalculator\Calculator\BaseCalculator; | ||
use EsteIt\ShippingCalculator\CalculatorHandler\IParcelCalculatorHandler; | ||
use EsteIt\ShippingCalculator\Model\Weight; | ||
use EsteIt\ShippingCalculator\Model\Dimensions; | ||
use EsteIt\ShippingCalculator\Model\Address; | ||
use EsteIt\ShippingCalculator\Model\Package; | ||
|
||
include_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
$config = include __DIR__.'/../src/Resources/IParcel/tariff_2015_01_12_usa.php'; | ||
|
||
$calculator = new BaseCalculator([ | ||
'handler' => IParcelCalculatorHandler::create($config) | ||
]); | ||
|
||
$weight = new Weight(); | ||
$weight->setValue(10); | ||
$weight->setUnit('lb'); | ||
|
||
$dimensions = new Dimensions(); | ||
$dimensions->setLength(10); | ||
$dimensions->setWidth(10); | ||
$dimensions->setHeight(10); | ||
$dimensions->setUnit('in'); | ||
|
||
$senderAddress = new Address(); | ||
$senderAddress->setCountryCode('USA'); | ||
|
||
$recipientAddress = new Address(); | ||
$recipientAddress->setCountryCode('SGP'); | ||
|
||
$package = new Package(); | ||
$package->setCalculationDate(new \DateTime()); | ||
$package->setWeight($weight); | ||
$package->setDimensions($dimensions); | ||
$package->setSenderAddress($senderAddress); | ||
$package->setRecipientAddress($recipientAddress); | ||
|
||
$result = $calculator->calculate($package); | ||
|
||
var_dump($result->getTotalCost()); | ||
|
Oops, something went wrong.