bedard/shipping
Composer 安装命令:
composer require bedard/shipping
包简介
API wrapper for shipping calculations.
关键字:
README 文档
README
A simple PHP wrapper for USPS shipping calulations.
Instructions
The first step to requesting a shipping quote is injecting your USPS Web Tools ID.
use Bedard\Shipping\Usps; $shipment = new Usps('123ABCDE4567');
If you would like to run the calculator on the USPS testing server, call useTestingServer().
$shipment->useTestingServer();
Once this is done, it's time to build up the data you'll be sending to USPS. Length, width, and height are all specified in inches. Pounds, ounces, and setValue() are all optional.
$rates = $shipment ->setOrigin('12345') ->setDestination('90210') ->setDimensions([ 'length' => 12, 'width' => 12, 'height' => 4, 'pounds' => 0, 'ounces' => 1 ]) ->setValue(49.99) ->calculate();
The above is an example of a domestic shipment. To request an international rate, simply pass the destination country into setDestination() instead of a postal code.
$shipment->setDestination('Canada');
Once you've called calculate(), shipping rates will be returned in the following format. Results will be ordered by cost in ascending order.
1 =>
array (size=3)
'code' => string '01' (length=2)
'name' => string 'First-Class Mail Large Envelope' (length=31)
'cost' => float 0.98
2 =>
array (size=3)
'code' => string '00' (length=2)
'name' => string 'First-Class Mail Parcel' (length=23)
'cost' => float 2.32
3 =>
array (size=3)
'code' => string '1' (length=1)
'name' => string 'Priority Mail 2-Day' (length=19)
'cost' => float 5.75
统计信息
- 总下载量: 110
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-09