royal mail price calculator
1.0.0
Esta biblioteca le permite calcular el costo de enviar un paquete con Royal Mail.
Incluye precios válidos a partir de marzo de 2017.
Instale la última versión con composer require justinhook/royal-mail-price-calculator
Servicio | Clase |
---|---|
1ra clase | FirstClassService() |
2da clase | SecondClassService() |
Firmado para 1ra clase | SignedForFirstClassService() |
Firmado para 2da clase | SignedForSecondClassService() |
Garantizado antes de las 9 a.m. | GuaranteedByNineAmService() |
Garantizado hasta las 9 a. m. con garantía del sábado | GuaranteedByNineAmWithSaturdayService() |
Garantizado hasta las 13:00 horas. | GuaranteedByOnePmService() |
Garantizado hasta las 13:00 horas con garantía del sábado. | GuaranteedByOnePmWithSaturdayService() |
<?php
require ' vendor/autoload.php ' ;
use 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" ;
}
Salida:
1st Class Service
→ £0.62 (Compensation: £20)
Guaranteed by 1pm
→ £6.40 (Compensation: £500)
→ £7.40 (Compensation: £1000)
→ £9.40 (Compensation: £2500)