此包已被废弃,不再维护。未建议替代包。

一个简单的工具,用于返回UPS运费。

v1.1.1 2016-01-19 14:37 UTC

This package is not auto-updated.

Last update: 2022-03-30 00:52:11 UTC


README

此包用于向UPS Web服务发送运费报价请求。

使用Composer安装,编辑你的composer.json文件以包含

"require": {
	"beaudierman/ups": "1.*"
}

从命令行更新Composer

composer update

在你的app/config/app.php文件中providers数组中添加一个新的服务提供者

'Beaudierman\Ups\UpsServiceProvider'

在相同的配置文件中,将类别名添加到aliases数组

'Ups'             => 'Beaudierman\Ups\Facades\Ups'

示例

$return = Ups::getQuote(
    array(
        'access_key' => 'your key',
        'username' => 'your username',
        'password' => 'your password',
        'account_number' => 'your account number',
    ),
	array(
		'from_zip' => '37902',
        'from_state' => 'TN', // Optional, may yield a more accurate quote
        'from_country' => 'US', // Optional, defaults to US
		'to_zip' => '90210',
        'to_state' => 'CA', // Optional, may yield a more accurate quote
        'to_country' => 'US', // Optional, defaults to US
		'packages' => 1,
		'weight' => 50,
        'measurement' => 'LBS', // Currently the UPS API will only allow LBS and KG, default is LBS
        'negotiated_rates' => true // Optional, set true to return negotiated rates from UPS
	)
);

返回值

Array
(
    [03] => Array
        (
            [service] => UPS Ground
            [rate] => 52.32
        )

    [12] => Array
        (
            [service] => UPS 3 Day Select
            [rate] => 145.09
        )

    [02] => Array
        (
            [service] => UPS 2nd Day Air
            [rate] => 235.40
        )

    [01] => Array
        (
            [service] => UPS Next Day Air
            [rate] => 301.46
        )

)