Skip to content

Commit

Permalink
Merge pull request #3 from sektor-sumy/i-parcel
Browse files Browse the repository at this point in the history
add i-parcel calculator
  • Loading branch information
moriony committed Jan 14, 2016
2 parents c9fe585 + 97aa501 commit c0f1d18
Show file tree
Hide file tree
Showing 7 changed files with 2,211 additions and 0 deletions.
44 changes: 44 additions & 0 deletions examples/calculate_iparcel_shipping.php
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());

Loading

0 comments on commit c0f1d18

Please sign in to comment.