royal mail price calculator
1.0.0
該庫允許您計算透過皇家郵政發送包裹的費用。
包括 2017 年 3 月起有效的價格。
使用composer require justinhook/royal-mail-price-calculator
服務 | 班級 |
---|---|
一等艙 | FirstClassService() |
二等艙 | SecondClassService() |
簽約一等獎 | SignedForFirstClassService() |
簽到二等獎 | SignedForSecondClassService() |
保證上午 9 點前 | GuaranteedByNineAmService() |
上午 9 點保證,週六保證 | GuaranteedByNineAmWithSaturdayService() |
保證下午 1 點前 | GuaranteedByOnePmService() |
下午 1 點前保證,週六保證 | 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" ;
}
將輸出:
1st Class Service
→ £0.62 (Compensation: £20)
Guaranteed by 1pm
→ £6.40 (Compensation: £500)
→ £7.40 (Compensation: £1000)
→ £9.40 (Compensation: £2500)