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)