Shipping component
The shipping component contains shipping-related tools.
would return Federal Express.
Return will either give you the array keys
The
Note that this does connect to the UPS service which requires you to initially create an account and set the credentials in the .config. Also, there is typically a noticeable lag getting a response from the UPS service.
Typical usage:
Shipping company abbreviations
get::component('shipping')->shippingCompanies
contains an array of shipping companies with keys of their common abbreviation and values of their full name eg.:echo get::component('shipping')->shippingCompanies['fedex'];
would return Federal Express.
Track a package
Theget::component('shipping')->trackingLinks
contains an array of URLs (one from each company in the shippingCompanies array above) that you can simply append a tracking number to and it will show the tracking information. Common usage would be:load::redirect(get::component('shipping')->trackingLinks['ups'] . $upsTrackingNumber);
Get live shipping rates from UPS
Theget::component('shipping')->getUpsRates(array $args)
method will return an array of available UPS shipping rates. All keys in $args
are optional, but you do need to supply some of them in order to get a meaningful response from UPS. Options are:originZip
destinationZip
originCountry
(the 2-digit country code)destinationCountry
(the 2-digit country code)weight
(in lbs.)pickupType
(as defined by UPS)serviceCode
(as defined by UPS)packagingType
(as defined by UPS)packagingDescription
(as defined by UPS)
Return will either give you the array keys
options
and optionsArray
or it will have an array key for error
. If it is error
then the value will be a string describing the error. The options
and optionsArray
are both arrays indexed by service code (defined in the next section about upsShipMethods
property.) In many cases you will only need options
which contains an array of human-readable shipping options. optionsArray
contains the full UPS response info as an array. Each service code in options
gets a subarray with keys:price
shipMethod
- the human-readable value that corresponds to the service codeguaranteedDaysToDelivery
scheduledDeliveryTime
raw
- the data as returned by UPS for this option in a SimpleXML object
The
guaranteedDaysToDelivery
and scheduledDeliveryTime
options may not be available for every ship method in which case it will return an empty string.Note that this does connect to the UPS service which requires you to initially create an account and set the credentials in the .config. Also, there is typically a noticeable lag getting a response from the UPS service.
Typical usage:
$args['weight'] = 2.5; $args['originZip'] = 90210; $args['destinationZip'] = 10027;
$rates = get::component('shipping')->getUpsRates($args);
UPS shipping methods
Theget::component('shipping')->upsShipMethods
array maps the UPS shipping method code to the human-readable name, eg.:get::component('shipping')->upsShipMethods[59]
is 2nd Day Air AM