<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexedimensionz / royal-mail-price-calculator example snippets
RoyalMailPriceCalculator\Calculator;
use \RoyalMailPriceCalculator\Package;
use \RoyalMailPriceCalculator\Services\GuaranteedByOnePmService;
use \RoyalMailPriceCalculator\Services\FirstClassService;
$calculator = new Calculator();
$package = new Package();
$package->setDimensions(15, 15, 0.4);
$package->setWeight(90);
$calculator->setServices(array(
new FirstClassService(),
new GuaranteedByOnePmService()));
foreach ($calculator->calculatePrice($package) as $calculated)
{
echo $calculated['service']->getName() . "\n";
foreach ($calculated['prices'] as $price) {
echo " → £{$price['price']} (Compensation: £{$price['compensation']})\n";
}
echo "\n";
}
RoyalMailPriceCalculator\Calculator;
use \RoyalMailPriceCalculator\Package;
use \RoyalMailPriceCalculator\Services\InternationalTracked;
use \RoyalMailPriceCalculator\Services\InternationalEconomy;
$calculator = new Calculator();
$package = new Package();
$package->setDimensions(15, 15, 0.4);
$package->setWeight(90);
// This part is mandatory for international shipments
$target_iso = 'US';
$calculator->setCountryCode($target_iso);
//
$calculator->setServices(array(
new InternationalTracked(),
new InternationalEconomy()));
// Note: there is no compensation value for international
foreach ($calculator->calculatePrice($package) as $calculated)
{
echo $calculated['service']->getName() . "\n";
foreach ($calculated['prices'] as $price) {
echo " → £{$price['price']}\n";
}
echo "\n";
}
RoyalMailPriceCalculator\Calculator;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.