Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / UPS Heavy Freight Module UPS Freight over 150 lbs.

UPS Heavy Freight Module UPS Freight over 150 lbs.

Views: 11,912

Results 1 to 16 of 16
16 Mar 2008, 10:36 PM
#1
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

UPS Heavy Freight Module UPS Freight over 150 lbs.

UPS Heavy Freight Module UPS Freight over 150 lbs.
Copyright 2007 Distributed under the terms of the GNUv3 General Public License .
UPS XML-RPC Interface is a simple XML-RPC
service for connecting to UPS for shipping estimates.
UPS XML-RPC Interface is written in PHP,
but can be accessed by any program
that can communicate with XML-RPC.

Here is the UPS side of the Module.
We have been looking for this for a long time.
A proper Module needs to be created.
let us all get behind this one and push.
--Links you will need, these libraries must be installed,
in your server.
http://phpxmlrpc.sourceforge.net/

http://sourceforge.net/projects/expat/

16 Mar 2008, 10:43 PM
#2
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Zen Cart UPS Heavy Freight Module
The other two Heavy Freight Modules,
are at these links,
with one class of Freight they are sign up and use.
FedEx Heavy Freight Module:
http://www.zen-cart.com/forum/showthread.php?t=88424
Con-Way Heavy Freight Module:
http://www.zen-cart.com/forum/showthread.php?t=85307&highlight=create+a+module

Build a Zen Cart UPS Heavy Freight Module
This is from a get's quotes from UPS working website.
--Start:
UPS XML-RPC Interface is a simple XML-RPC
service for connecting to UPS for shipping estimates.
UPS XML-RPC Interface is written in PHP,
but can be accessed by any program
that can communicate with XML-RPC.

UPS XML-RPC Interface is released under the GPLv3 license.

This is a first stab at creating an easy-to-use,
language neutral, interface for getting a shipping estimate from UPS.
So far it seems to work perfectly for our needs but bugs are likely.

To install the UPS XML-RPC interface you'll need to compile Apache with CURL,
expat, and XML-RPC.
You'll need this on the server you're running
the UPS XML-RPC interface on and,
if different, also on the server your application is running on.

In your PHP application you'll need a function to make XML-RPC requests.
I've provided an example below.
Any programming language that can make XML-RPC requests
can make requests of the UPS XML-RPC interface in a similar way.


function remoteRequest ( $server, $method, $params ) {
$req = xmlrpc_encode_request ( $method, $params );
$headers = array (
'Content-Type: text/xml',
'Content-Length: ' . strlen ( $req )
);
$ch = curl_init ( "http://$server/" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, True );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 600 );
set_time_limit ( 600 );
$resp = curl_exec ( $ch );
set_time_limit ( 30 );
curl_close ( $ch );
return xmlrpc_decode ( $resp );
}

The structure of the XML-RPC request,
is very similar to the XML requests documented in the
'UPS OnLine Tools Rates and Service Selection Developers Guide'.

$resp = remoteRequest ( 'ups', 'ratingServiceSelectionRequest', $upsParams );

From your PHP application you can connect to a server,
'ups', and run the function, 'ratingServiceSelectionRequest',
with the options defined in an array, $upsParams.
The result will be returned as the $resp array.

To define your array that you'll submit there are several common options.
You'll need a UPS shipper number, access key, username, and password.
You'll also need to know the shipper's postal code, state code,
and country code and the destination postal code, state code, and country code.
You'll need to define one or more packages.
Shipments of more than 150lbs will need to go by UPS Freight.
Smaller packages can be shipped by UPS Ground but must be calculated separately.
Below is a sample package definition.
You can define the dimensions of the package if you know them,
for a more accurate shipping estimate.
One or more packages should be put into a $packages array.


$package = array (
'packagingType' => array (
'code' => '02' // Customer supplied packaging.
),
'dimensions' => array (
'unitOfMeasurement' => array (
'code' => 'IN'
),
'length' => 1,
'width' => 1,
'height' => 1
),
'packageWeight' => array (
'unitOfMeasurement' => array (
'code' => 'LBS'
),
'weight' => $weight
)
);

Below is an example of a full options array.


$upsParams = array (
'accessKey' => UPS_ACCESS_KEY,
'username' => UPS_USERNAME,
'password' => UPS_PASSWORD,
'request' => array (
'requestAction' => 'rate',
'requestOption' => 'Rate'
),
'pickupType' => array (
'code' => '03' // customer counter
),
'customerClassification' => array (
'code' => '04' // retail
),
'shipment' => array (
'service' => array (
'code' => $service // UPS Freight (308) or UPS Ground (03)
),
'shipper' => array (
'shipperNumber' => UPS_SHIP_NUMBER,
'address' => array (
'postalCode' => UPS_SHIPPER_POSTAL,
'stateProvinceCode' => UPS_SHIPPER_STATE,
'countryCode' => UPS_SHIPPER_COUNTRY
)
),
'shipTo' => array (
'address' => array (
'postalCode' => $postalCode,
'stateProvinceCode' => $state,
'countryCode' => $country
)
),
'packages' => $packages
)
);


You'll need to check your response array to see if your request succeeded.
If so, you'll probably want to add up all the charges.
Otherwise you'll want to respond to the error in some way.
Sample code to do this is below.


if ( $resp['response']['responseStatusCode'] == 1 ) {
$shipping = 0.00;
foreach ( $resp['ratedShipments'] as $ratedShipment ) {
$shipping = $shipping + (float) $ratedShipment['totalCharges']['monetaryValue'];
}
} else {
// an error has occured. do something.
}

Now you have a good estimate of the shipping charges. Add your handling fee and you're done.

16 Mar 2008, 10:55 PM
#3
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Ups Heavy Freight Module Freight over 150 lbs.
The UPS side of the Module let us build,
a UPS Heavy Freight Module for Freight over 150 lbs

---Starts the long version
ups_xmlrpc_interface/ $xml ) {
$this->xmlParser ( $xml );
// Response
if ( list ( $response, ) = $this->getElementsByTag ( 'Response' ) ) {
// TransactionReference
if ( list ( $transactionReference, ) = $response->getChildrenByTag ( 'TransactionReference' ) ) {
$tRef = array ();
if ( list ( $customerContext, ) = $transactionReference->getChildrenByTag ( 'CustomerContext' ) ) {
$tRef['customerContext'] = $customerContext->getCdata ();
}
if ( list ( $xpciVersion, ) = $transactionReference->getChildrenByTag ( 'XpciVersion' ) ) {
$tRef['xpciVersion'] = $xpciVersion->getCdata ();
}
$this->response['transactionReference'] = $tRef;
}
// ResponseStatusCode
list ( $responseStatusCode, ) = $response->getChildrenByTag ( 'ResponseStatusCode' );
$this->response['responseStatusCode'] = $responseStatusCode->getCdata ();
// ResponseStatusDescription
if ( list ( $responseStatusDescription, ) = $response->getChildrenByTag ( 'ResponseStatusDescription' ) ) {
$this->response['responseStatusDescription'] = $responseStatusDescription->getCdata ();
}
// Errors
if ( $errors = $response->getChildrenByTag ( 'Error' ) ) {
$errs = array ();
foreach ( $errors as $error ) {
$err = array ();
list ( $errorSeverity, ) = $error->getChildrenByTag ( 'ErrorSeverity' );
$err['errorSeverity'] = $errorSeverity->getCdata ();
list ( $errorCode, ) = $error->getChildrenByTag ( 'ErrorCode' );
$err['errorCode'] = $errorCode->getCdata ();
if ( list ( $errorDescription, ) = $error->getChildrenByTag ( 'ErrorDescription' ) ) {
$err['errorDescription'] = $errorDescription->getCdata ();
}
if ( list ( $minimumRetrySeconds, ) = $error->getChildrenByTag ( 'MinimumRetrySeconds' ) ) {
$err['minimumRetrySeconds'] = $minimumRetrySeconds->getCdata ();
}
if ( $errorLocations = $error->getChildrenByTag ( 'ErrorLocation' ) ) {
$errLocs = array ();
foreach ( $errorLocations as $errorLocation ) {
$errLoc = array ();
if ( list ( $errorLocationElementName, ) = $errorLocation->getChildrenByTag ( 'ErrorLocationElementName' ) ) {
$errLoc['errorLocationElementName'] = $errorLocationElementName->getCdata ();
}
if ( list ( $errorLocationElementReference, ) = $errorLocation->getChildrenByTag ( 'ErrorLocationElementReference' ) ) {
$errLoc['errorLocationElementReference'] = $errorLocationElementReference->getCdata ();
}
if ( list ( $errorLocationAttributeName, ) = $errorLocation->getChildrenByTag ( 'ErrorLocationAttributeName' ) ) {
$errLoc['errorLocationAttributeName'] = $errorLocationAttributeName->getCdata ();
}
$errLocs[] = $errLoc;
}
$err['errorLocations'] = $errLocs;
}
if ( $errorDigests = $error->getChildrenByTag ( 'ErrorDigest' ) ) {
$errDigs = array ();
foreach ( $errorDigests as $errorDigest ) {
$errDigs[] = $errorDigest->getCdata ();
}
$err['errorDigests'] = $errDigs;
}
$errs[] = $err;
}
$this->response['errors'] = $errs;
}
}

// RatedShipments
if ( $ratedShipments = $this->getElementsByTag ( 'RatedShipment' ) ) {
$ships = array ();
foreach ( $ratedShipments as $ratedShipment ) {
$ship = array ();
// Service
list ( $service, ) = $ratedShipment->getChildrenByTag ( 'Service' );
$srv = array ();
list ( $code, ) = $service->getChildrenByTag ( 'Code' );
$srv['code'] = $code->getCdata ();
if ( list ( $description, ) = $ratedShipment->getChildrenByTag ( 'Description' ) ) {
$srv['description'] = $description->getCdata ();
}
$ship['service'] = $srv;
// RatedShipmentWarnings
if ( $ratedShipmentWarnings = $ratedShipment->getChildrenByTag ( 'RatedShipmentWarning' ) ) {
$warnings = array ();
foreach ( $ratedShipmentWarnings as $ratedShipmentWarning ) {
$warnings[] = $ratedShipmentWarning->getCdata ();
}
$ship['ratedShipmentWarnings'] = $warnings;
}
// BillingWeight
if ( list ( $billingWeight, ) = $ratedShipment->getChildrenByTag ( 'BillingWeight' ) ) {
$bw = array ();
list ( $unitOfMeasurement, ) = $billingWeight->getChildrenByTag ( 'UnitOfMeasurement' );
$uom = array ();
list ( $code, ) = $unitOfMeasurement->getChildrenByTag ( 'Code' );
$uom['code'] = $code->getCdata ();
if ( list ( $description, ) = $unitOfMeasurement->getChildrenByTag ( 'Description' ) ) {
$uom['description'] = $description->getCdata ();
}
$bw['unitOfMeasurement'] = $uom;
list ( $weight, ) = $billingWeight->getChildrenByTag ( 'Weight' );
$bw['weight'] = $weight->getCdata ();
$ship['billingWeight'] = $bw;
}
// TransportationCharges
list ( $transportationCharges, ) = $ratedShipment->getChildrenByTag ( 'TransportationCharges' );
$tChrg = array ();
if ( list ( $currencyCode, ) = $transportationCharges->getChildrenByTag ( 'CurrencyCode' ) ) {
$tChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $transportationCharges->getChildrenByTag ( 'MonetaryValue' );
$tChrg['monetaryValue'] = $monetaryValue->getCdata ();
$ship['transportationCharges'] = $tChrg;
// ServiceOptionsCharges
if ( list ( $serviceOptionsCharges, ) = $ratedShipment->getChildrenByTag ( 'ServiceOptionsCharges' ) ) {
$sChrg = array ();
if ( list ( $currencyCode, ) = $serviceOptionsCharges->getChildrenByTag ( 'CurrencyCode' ) ) {
$sChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $serviceOptionsCharges->getChildrenByTag ( 'MonetaryValue' );
$sChrg['monetaryValue'] = $monetaryValue->getCdata ();
$ship['serviceOptionsCharges'] = $sChrg;
}
// HandlingChargeAmount
if ( list ( $handlingChargeAmount, ) = $ratedShipment->getChildrenByTag ( 'HandlingChargeAmount' ) ) {
$hChrg = array ();
if ( list ( $currencyCode, ) = $handlingChargeAmount->getChildrenByTag ( 'CurrencyCode' ) ) {
$hChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $handlingChargeAmount->getChildrenByTag ( 'MonetaryValue' );
$hChrg['monetaryValue'] = $monetaryValue->getCdata ();
$ship['serviceOptionsCharges'] = $hChrg;
}
// TotalCharges
list ( $totalCharges, ) = $ratedShipment->getChildrenByTag ( 'TotalCharges' );
$tChrg = array ();
if ( list ( $currencyCode, ) = $totalCharges->getChildrenByTag ( 'CurrencyCode' ) ) {
$tChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $totalCharges->getChildrenByTag ( 'MonetaryValue' );
$tChrg['monetaryValue'] = $monetaryValue->getCdata ();
$ship['totalCharges'] = $tChrg;
// GuaranteedDaysToDelivery
list ( $guaranteedDaysToDelivery, ) = $ratedShipment->getChildrenByTag ( 'GuaranteedDaysToDelivery' );
$ship['guaranteedDaysToDelivery'] = $guaranteedDaysToDelivery->getCdata ();
// ScheduledDeliveryTime
list ( $scheduledDeliveryTime, ) = $ratedShipment->getChildrenByTag ( 'ScheduledDeliveryTime' );
$ship['scheduledDeliveryTime'] = $scheduledDeliveryTime->getCdata ();
// RatedPackages
$ratedPackages = $ratedShipment->getChildrenByTag ( 'RatedPackage' );
$pkgs = array ();
foreach ( $ratedPackages as $ratedPackage ) {
$pkg = array ();
list ( $transportationCharges, ) = $ratedPackage->getChildrenByTag ( 'TransportationCharges' );
$tChrg = array ();
if ( list ( $currencyCode, ) = $transportationCharges->getChildrenByTag ( 'CurrencyCode' ) ) {
$tChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $transportationCharges->getChildrenByTag ( 'MonetaryValue' );
$tChrg['monetaryValue'] = $monetaryValue->getCdata ();
$pkg['transportationCharges'] = $tChrg;
if ( list ( $serviceOptionsCharges, ) = $ratedPackage->getChildrenByTag ( 'ServiceOptionsCharges' ) ) {
$sChrg = array ();
if ( list ( $currencyCode, ) = $serviceOptionsCharges->getChildrenByTag ( 'CurrencyCode' ) ) {
$sChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $serviceOptionsCharges->getChildrenByTag ( 'MonetaryValue' );
$sChrg['monetaryValue'] = $monetaryValue->getCdata ();
$pkg['serviceOptionsCharges'] = $sChrg;
}
list ( $totalCharges, ) = $ratedPackage->getChildrenByTag ( 'TotalCharges' );
$tChrg = array ();
if ( list ( $currencyCode, ) = $totalCharges->getChildrenByTag ( 'CurrencyCode' ) ) {
$tChrg['currencyCode'] = $currencyCode->getCdata ();
}
list ( $monetaryValue, ) = $totalCharges->getChildrenByTag ( 'MonetaryValue' );
$tChrg['monetaryValue'] = $monetaryValue->getCdata ();
$pkg['totalCharges'] = $tChrg;
list ( $weight, ) = $ratedPackage->getChildrenByTag ( 'Weight' );
$pkg['weight'] = $weight->getCdata ();
if ( list ( $billingWeight, ) = $ratedPackage->getChildrenByTag ( 'BillingWeight' ) ) {
$bw = array ();
list ( $unitOfMeasurement, ) = $billingWeight->getChildrenByTag ( 'UnitOfMeasurement' );
$uom = array ();
list ( $code, ) = $unitOfMeasurement->getChildrenByTag ( 'Code' );
$uom['code'] = $code->getCdata ();
if ( list ( $description, ) = $unitOfMeasurement->getChildrenByTag ( 'Description' ) ) {
$uom['description'] = $description->getCdata ();
}
$bw['unitOfMeasurement'] = $uom;
list ( $weight, ) = $billingWeight->getChildrenByTag ( 'Weight' );
$bw['weight'] = $weight->getCdata ();
$pkg['billingWeight'] = $bw;
}
$pkgs[] = $pkg;
}
$ship['ratedPackages'] = $pkgs;
// NegotiatedRates
if ( list ( $negotiatedRates, ) = $ratedShipment->getChildrenByTag ( 'NegotiatedRates' ) ) {
$neg = array ();
list ( $netSummaryCharges, ) = $negotiatedRates->getChildrenByTag ( 'NetSummaryCharges' );
$net = array ();
list ( $grandTotal, ) = $netSummaryCharges->getChildrenByTag ( 'GrandTotal' );
$total = array ();
list ( $currencyCode, ) = $grandTotal->getChildrenByTag ( 'CurrencyCode' );
$total['currencyCode'] = $currencyCode->getCdata ();
list ( $monetaryValue, ) = $grandTotal->getChildrenByTag ( 'MonetaryValue' );
$total['monetaryValue'] = $monetaryValue->getCdata ();
$net['grandTotal'] = $total;
$neg['netSummaryCharges'] = $net;
$ship['negotiatedRates'] = $neg;
}
$ships[] = $ship;
}
$this->ratedShipments = $ships;
}
}
function getResponse () {
return $this->response;
}
function getRatedShipments () {
return $this->ratedShipments;
}
}

?>

16 Mar 2008, 10:59 PM
#4
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

<? // Copyright 2007 Distributed under the terms of the GNU General Public License version 3. /* This file is part of UPS XML-RPC Interface. UPS XML-RPC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. UPS XML-RPC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with UPS XML-RPC. If not, see <http://www.gnu.org/licenses/>. */ class xmlObject { var $tag; var $attributes; var $children; function xmlObject ( $tag, $attributes = Null, $children = Null ) { $this->tag = $tag; $this->attributes = $attributes ? $attributes : array (); $this->children = $children ? $children : array (); } function getTag () { return $this->tag; } function setTag ( $tag ) { $this->tag = $tag; } function getAttributes () { return $this->attributes; } function getAttribute ( $var ) { return $this->attributes[$var]; } function setAttribute ( $var, $value ) { $this->attributes[$var] = $value; } function unsetAttribute ( $var ) { unset ( $this->attributes[$var] ); } function getChildren () { return $this->children; } function appendChild ( $child ) { $this->children[] = $child; } function appendChildren ( $children ) { foreach ( $children as $child ) { $this->appendChild ( $child ); } } function getChildrenByTag ( $tag ) { $elements = array (); if ( $this->children ) { foreach ( $this->children as $child ) { if ( $child->tag && $child->tag == $tag ) { $elements[] = $child; } } } return $elements; } function getCdata () { $cdata = array (); if ( $this->children ) { foreach ( $this->children as $child ) { if ( $child->cdata != '' ) { $cdata[] = $child->cdata; } } } return implode ( ' ', $cdata ); } function xmlAttributes () { $attribs = array (); if ( $this->attributes ) { while ( list ( $var, $value ) = each ( $this->attributes ) ) { $attribs[] = "$var=\"$value\""; } } return implode ( ' ', $attribs ); } function xmlChildren () { $xml = ''; if ( $this->children ) { foreach ( $this->children as $child ) { if ( isset ( $child->cdata ) ) { $xml .= $child->xml (); $cEnd = True; } else { foreach ( explode ( "\n", $child->xml () ) as $line ) { $xml .= "\n $line"; $cEnd = False; } } } if ( ! $cEnd ) { $xml = "$xml\n"; } } return $xml; } function xml () { $xmlTag = $this->tag; $xmlAttributes = $this->xmlAttributes (); $xmlChildren = $this->xmlChildren (); if ( isset ( $xmlChildren ) ) { $xml = $xmlAttributes ? "<$xmlTag $xmlAttributes>$xmlChildren</$xmlTag>" :"<$xmlTag>$xmlChildren</$xmlTag>" ; } else { $xml = $xmlAttributes ? "<$xmlTag $xmlAttributes/>" : "<$xmlTag/>"; } return $xml; } function xmlDocument () { $xml = $this->xml (); $doc = <<<EndDoc <?xml version="1.0" ?>

$xml
EndDoc;
return $doc;
}
}

class cdataObject {
var $cdata;

function cdataObject ( $cdata ) {
$this->cdata = $cdata;
}

function xml () {
return $this->cdata;
}
}

class combinedObject extends xmlObject {
function combinedObject ( $tag, $cdata, $attributes = Null ) {
$this->xmlObject ( $tag, $attributes );
$this->appendChild ( new cdataObject ( $cdata ) );
}
}

class doubleCombinedObject extends xmlObject {
function doubleCombinedObject ( $tag1, $tag2, $cdata ) {
$this->xmlObject ( $tag1 );
$this->appendChild ( new combinedObject ( $tag2, $cdata ) );
}
}

?>
'Content-Length: ' . strlen ( $req )
);
$ch = curl_init ( "http://$server/" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, True );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 600 );
set_time_limit ( 600 );
$resp = curl_exec ( $ch );
set_time_limit ( 30 );
curl_close ( $ch );
return xmlrpc_decode ( $resp );
}

The structure of the XML-RPC request is very similar to the XML
requests documented in the 'UPS OnLine Tools Rates and Service
Selection Developers Guide'.

$resp = remoteRequest ( 'ups', 'ratingServiceSelectionRequest', $upsParams );

From your PHP application you can connect to a server, 'ups', and run
the function, 'ratingServiceSelectionRequest', with the options defined
in an array, $upsParams. The result will be returned as the $resp
array.

To define your array that you'll submit there are several common
options. You'll need a UPS shipper number, access key, username, and
password. You'll also need to know the shipper's postal code, state
code, and country code and the destination postal code, state code, and
country code.

You'll need to define one or more packages. Shipments of more than
150lbs will need to go by UPS Freight. Smaller packages can be shipped
by UPS Ground but must be calculated separately.

Below is a sample package definition. You can define the dimensions of
the package if you know them for a more accurate shipping estimate. One
or more packages should be put into a $packages array.


$package = array (
'packagingType' => array (
'code' => '02' // Customer supplied packaging.
),
'dimensions' => array (
'unitOfMeasurement' => array (
'code' => 'IN'
),
'length' => 1,
'width' => 1,
'height' => 1
),
'packageWeight' => array (
'unitOfMeasurement' => array (
'code' => 'LBS'
),
'weight' => $weight
)
);

Below is an example of a full options array.


$upsParams = array (
'accessKey' => UPS_ACCESS_KEY,
'username' => UPS_USERNAME,
'password' => UPS_PASSWORD,
'request' => array (
'requestAction' => 'rate',
'requestOption' => 'Rate'
),
'pickupType' => array (
'code' => '03' // customer counter
),
'customerClassification' => array (
'code' => '04' // retail
),
'shipment' => array (
'service' => array (
'code' => $service // UPS Freight (308) or UPS Ground (03)
),
'shipper' => array (
'shipperNumber' => UPS_SHIP_NUMBER,
'address' => array (
'postalCode' => UPS_SHIPPER_POSTAL,
'stateProvinceCode' => UPS_SHIPPER_STATE,
'countryCode' => UPS_SHIPPER_COUNTRY
)
),
'shipTo' => array (
'address' => array (
'postalCode' => $postalCode,
'stateProvinceCode' => $state,
'countryCode' => $country
)
),
'packages' => $packages
)
);


You'll need to check your response array to see if your request
succeeded. If so, you'll probably want to add up all the charges.
Otherwise you'll want to respond to the error in some way. Sample code
to do this is below.


if ( $resp['response']['responseStatusCode'] == 1 ) {
$shipping = 0.00;
foreach ( $resp['ratedShipments'] as $ratedShipment ) {
$shipping = $shipping + (float) $ratedShipment['totalCharges']['monetaryValue'];
}
} else {
// an error has occured. do something.
}

Now you have a good estimate of the shipping charges. Add your handling
fee and you're done.

16 Mar 2008, 11:05 PM
#5
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

eNumber = new combinedObject ( 'PhoneLineNumber', $shipmnt['shipper']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipper']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $shipmnt['shipper']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $shipmnt['shipper']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $shipmnt['shipper']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipper']['phoneNumber'] );
}
$shipper->appendChild ( $phoneNumber );
}
if ( $shipmnt['shipper']['faxNumber'] ) {
$faxNumber = new combinedObject ( 'FaxNumber', $shipmnt['shipper']['faxNumber'] );
$shipper->appendChild ( $faxNumber );
}
if ( $shipmnt['shipper']['shipperNumber'] ) {
$shipperNumber = new combinedObject ( 'ShipperNumber', $shipmnt['shipper']['shipperNumber'] );
$shipper->appendChild ( $shipperNumber );
}
if ( $shipmnt['shipper']['address'] ) {
$countryCode = new combinedObject ( 'CountryCode', $shipmnt['shipper']['address']['countryCode'] );
$address = new xmlObject ( 'Address', Null, array ( $countryCode ) );
if ( $shipmnt['shipper']['address']['addressLine1'] ) {
$addressLine1 = new combinedObject ( 'AddressLine1', $shipmnt['shipper']['address']['addressLine1'] );
$address->appendChild ( $addressLine1 );
}
if ( $shipmnt['shipper']['address']['addressLine2'] ) {
$addressLine2 = new combinedObject ( 'AddressLine2', $shipmnt['shipper']['address']['addressLine2'] );
$address->appendChild ( $addressLine2 );
}
if ( $shipmnt['shipper']['address']['addressLine3'] ) {
$addressLine3 = new combinedObject ( 'AddressLine3', $shipmnt['shipper']['address']['addressLine3'] );
$address->appendChild ( $addressLine3 );
}
if ( $shipmnt['shipper']['address']['city'] ) {
$city = new combinedObject ( 'City', $shipmnt['shipper']['address']['city'] );
$address->appendChild ( $city );
}
if ( $shipmnt['shipper']['address']['stateProvinceCode'] ) {
$stateProvinceCode = new combinedObject ( 'StateProvinceCode', $shipmnt['shipper']['address']['stateProvinceCode'] );
$address->appendChild ( $stateProvinceCode );
}
if ( $shipmnt['shipper']['address']['postalCode'] ) {
$postalCode = new combinedObject ( 'PostalCode', $shipmnt['shipper']['address']['postalCode'] );
$address->appendChild ( $postalCode );
}
if ( $shipmnt['shipper']['address']['residentialAddress'] ) {
$residentialAddress = new combinedObject ( 'ResidentialAddress', $shipmnt['shipper']['address']['residentialAddress'] );
$address->appendChild ( $residentialAddress );
}
if ( $shipmnt['shipper']['address']['residentialAddressIndicator'] ) {
$residentialAddressIndicator = new combinedObject ( 'ResidentialAddressIndicator', $shipmnt['shipper']['address']['residentialAddressIndicator'] );
$address->appendChild ( $residentialAddressIndicator );
}
$shipper->appendChild ( $address );
}
// ShipTo
$countryCode = new combinedObject ( 'CountryCode', $shipmnt['shipTo']['address']['countryCode'] );
$address = new xmlObject ( 'Address', Null, array ( $countryCode ) );
if ( $shipmnt['shipTo']['address']['addressLine1'] ) {
$addressLine1 = new combinedObject ( 'AddressLine1', $shipmnt['shipTo']['address']['addressLine1'] );
$address->appendChild ( $addressLine1 );
}
if ( $shipmnt['shipTo']['address']['addressLine2'] ) {
$addressLine2 = new combinedObject ( 'AddressLine2', $shipmnt['shipTo']['address']['addressLine2'] );
$address->appendChild ( $addressLine2 );
}
if ( $shipmnt['shipTo']['address']['addressLine3'] ) {
$addressLine3 = new combinedObject ( 'AddressLine3', $shipmnt['shipTo']['address']['addressLine3'] );
$address->appendChild ( $addressLine3 );
}
if ( $shipmnt['shipTo']['address']['city'] ) {
$city = new combinedObject ( 'City', $shipmnt['shipTo']['address']['city'] );
$address->appendChild ( $city );
}
if ( $shipmnt['shipTo']['address']['stateProvinceCode'] ) {
$stateProvinceCode = new combinedObject ( 'StateProvinceCode', $shipmnt['shipTo']['address']['stateProvinceCode'] );
$address->appendChild ( $stateProvinceCode );
}
if ( $shipmnt['shipTo']['address']['postalCode'] ) {
$postalCode = new combinedObject ( 'PostalCode', $shipmnt['shipTo']['address']['postalCode'] );
$address->appendChild ( $postalCode );
}
if ( $shipmnt['shipTo']['address']['residentialAddress'] ) {
$residentialAddress = new combinedObject ( 'ResidentialAddress', $shipmnt['shipTo']['address']['residentialAddress'] );
$address->appendChild ( $residentialAddress );
}
if ( $shipmnt['shipTo']['address']['residentialAddressIndicator'] ) {
$residentialAddressIndicator = new combinedObject ( 'ResidentialAddressIndicator', $shipmnt['shipTo']['address']['residentialAddressIndicator'] );
$address->appendChild ( $residentialAddressIndicator );
}
$shipTo = new xmlObject ( 'ShipTo', Null, array ( $address ) );
if ( $shipmnt['shipTo']['shipperAssignedIdentificationNumber'] ) {
$shipperAssignedIdentificationNumber = new combinedObject ( 'ShipperAssignedIdentificationNumber', $shipmnt['shipTo']['shipperAssignedIdentificationNumber'] );
$shipTo->appendChild ( $shipperAssignedIdentificationNumber );
}
if ( $shipmnt['shipTo']['companyName'] ) {
$companyName = new combinedObject ( 'CompanyName', $shipmnt['shipTo']['companyName'] );
$shipTo->appendChild ( $companyName );
}
if ( $shipmnt['shipTo']['attentionName'] ) {
$attentionName = new combinedObject ( 'AttentionName', $shipmnt['shipTo']['attentionName'] );
$shipTo->appendChild ( $attentionName );
}
if ( $shipmnt['shipTo']['phoneNumber'] ) {
if ( is_array ( $shipmnt['shipTo']['phoneNumber'] ) ) {
$phoneDialPlanNumber = new combinedObject ( 'PhoneDialPlanNumber', $shipmnt['shipTo']['phoneNumber']['phoneDialPlanNumber'] );
$phoneLineNumber = new combinedObject ( 'PhoneLineNumber', $shipmnt['shipTo']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipTo']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $shipmnt['shipTo']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $shipmnt['shipTo']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $shipmnt['shipTo']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipTo']['phoneNumber'] );
}
$shipper->appendChild ( $phoneNumber );
}
if ( $shipmnt['shipTo']['taxIdentificationNumber'] ) {
$taxIdentificationNumber = new combinedObject ( 'TaxIdentificationNumber', $shipmnt['shipTo']['taxIdentificationNumber'] );
$shipTo->appendChild ( $taxIdentificationNumber );
}
if ( $shipmnt['shipTo']['faxNumber'] ) {
$faxNumber = new combinedObject ( 'FaxNumber', $shipmnt['shipTo']['faxNumber'] );
$shipTo->appendChild ( $faxNumber );
}
if ( $shipmnt['shipTo']['locationId'] ) {
$locationId = new combinedObject ( 'LocationID', $shipmnt['shipTo']['locationId'] );
$shipTo->appendChild ( $locationId );
}
$shipment = new xmlObject ( 'Shipment', Null, array ( $shipper, $shipTo ) );
// Description
if ( $shipmnt['description'] ) {
$description = new combinedObject ( 'Description', $shipmnt['description'] );
$shipment->appendChild ( $description );
}
// ShipFrom
if ( $shipmnt['shipFrom'] ) {
$companyName = new combinedObject ( 'CompanyName', $shipmnt['shipFrom']['companyName'] );
if ( is_array ( $shipmnt['shipFrom']['phoneNumber'] ) ) {
$phoneDialPlanNumber = new combinedObject ( 'PhoneDialPlanNumber', $shipmnt['shipFrom']['phoneNumber']['phoneDialPlanNumber'] );
$phoneLineNumber = new combinedObject ( 'PhoneLineNumber', $shipmnt['shipFrom']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipFrom']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $shipmnt['shipFrom']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $shipmnt['shipFrom']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $shipmnt['shipFrom']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipFrom']['phoneNumber'] );
}
$countryCode = new combinedObject ( 'CountryCode', $shipmnt['shipFrom']['address']['countryCode'] );
$address = new xmlObject ( 'Address', Null, array ( $countryCode ) );
if ( $shipmnt['shipFrom']['address']['addressLine1'] ) {
$addressLine1 = new combinedObject ( 'AddressLine1', $shipmnt['shipFrom']['address']['addressLine1'] );
$address->appendChild ( $addressLine1 );
}
if ( $shipmnt['shipFrom']['address']['addressLine2'] ) {
$addressLine2 = new combinedObject ( 'AddressLine2', $shipmnt['shipFrom']['address']['addressLine2'] );
$address->appendChild ( $addressLine2 );
}
if ( $shipmnt['shipFrom']['address']['addressLine3'] ) {
$addressLine3 = new combinedObject ( 'AddressLine3', $shipmnt['shipFrom']['address']['addressLine3'] );
$address->appendChild ( $addressLine3 );
}
if ( $shipmnt['shipFrom']['address']['city'] ) {
$city = new combinedObject ( 'City', $shipmnt['shipFrom']['address']['city'] );
$address->appendChild ( $city );
}
if ( $shipmnt['shipFrom']['address']['stateProvinceCode'] ) {
$stateProvinceCode = new combinedObject ( 'StateProvinceCode', $shipmnt['shipFrom']['address']['stateProvinceCode'] );
$address->appendChild ( $stateProvinceCode );
}
if ( $shipmnt['shipFrom']['address']['postalCode'] ) {
$postalCode = new combinedObject ( 'PostalCode', $shipmnt['shipFrom']['address']['postalCode'] );
$address->appendChild ( $postalCode );
}
if ( $shipmnt['shipFrom']['address']['residentialAddress'] ) {
$residentialAddress = new combinedObject ( 'ResidentialAddress', $shipmnt['shipFrom']['address']['residentialAddress'] );
$address->appendChild ( $residentialAddress );
}
if ( $shipmnt['shipFrom']['address']['residentialAddressIndicator'] ) {
$residentialAddressIndicator = new combinedObject ( 'ResidentialAddressIndicator', $shipmnt['shipFrom']['address']['residentialAddressIndicator'] );
$address->appendChild ( $residentialAddressIndicator );
}
$shipFrom = new xmlObject ( 'ShipFrom', Null, array ( $companyName, $phoneNumber, $address ) );
if ( $shipmnt['shipFrom']['attentionName'] ) {
$attentionName = new combinedObject ( 'AttentionName', $shipmnt['shipFrom']['attentionName'] );
$shipFrom->appendChild ( $attentionName );
}
if ( $shipmnt['shipFrom']['faxNumber'] ) {
$faxNumber = new combinedObject ( 'FaxNumber', $shipmnt['shipFrom']['faxNumber'] );
$shipFrom->appendChild ( $faxNumber );
}
$shipment->appendChild ( $shipFrom );
}
// ShipmentWeight
if ( $shipmnt['shipmentWeight'] ) {
$code = new combinedObject ( 'Code', $shipmnt['shipmentWeight']['code'] );
$weight = new combinedObject ( 'Weight', $shipmnt['shipmentWeight']['weight'] );
$unitOfMeasurement = new xmlObject ( 'UnitOfMeasurement', Null, array ( $code, $weight ) );
$shipmentWeight = new xmlObject ( 'ShipmentWeight', Null, array ( $unitOfMeasurement ) );
if ( $shipmnt['shipmentWeight']['description'] ) {
$description = new combinedObject ( 'Description', $shipmnt['shipmentWeight']['description'] );
$shipmentWeight->appendChild ( $description );
}
$shipment->appendChild ( $shipmentWeight );
}
// ReferenceNumber
if ( $shipmnt['referenceNumber'] ) {
$code = new combinedObject ( 'Code', $shipmnt['referenceNumber']['code'] );
$value = new combinedObject ( 'Value', $shipmnt['referenceNumber']['value'] );
$referenceNumber = new xmlObject ( 'ReferenceNumber', Null, array ( $code, $value ) );
$shipment->appendChild ( $referenceNumber );
}
// Service
if ( $shipmnt['service'] ) {
$code = new combinedObject ( 'Code', $shipmnt['service']['code'] );
$service = new xmlObject ( 'Service', Null, array ( $code ) );
if ( $shipmnt['service']['description'] ) {
$description = new combinedObject ( 'Description', $shipmnt['service']['description'] );
$service->appendChild ( $description );
}
$shipment->appendChild ( $service );
}
// PickupDate
if ( $shipmnt['pickupDate'] ) {
$pickupDate = new combinedObject ( 'PickupDate', $shipmnt['pickupDate'] );
$shipment->appendChild ( $pickupDate );
}
// ScheduledDeliveryDate
if ( $shipmnt['scheduledDeliveryDate'] ) {
$scheduledDeliveryDate = new combinedObject ( 'ScheduledDeliveryDate', $shipmnt['scheduledDeliveryDate'] );
$shipment->appendChild ( $scheduledDeliveryDate );
}
// ScheduledDeliveryTime
if ( $shipmnt['scheduledDeliveryTime'] ) {
$scheduledDeliveryTime = new combinedObject ( 'ScheduledDeliveryTime', $shipmnt['scheduledDeliveryTime'] );
$shipment->appendChild ( $scheduledDeliveryTime );
}
// AlternateDeliveryTime
if ( $shipmnt['alternateDeliveryTime'] ) {
$alternateDeliveryTime = new combinedObject ( 'AlternateDeliveryTime', $shipmnt['alternateDeliveryTime'] );
$shipment->appendChild ( $alternateDeliveryTime );
}
// DocumentsOnly
if ( $shipmnt['documentsOnly'] ) {
$documentsOnly = new combinedObject ( 'DocumentsOnly', $shipmnt['documentsOnly'] );
$shipment->appendChild ( $documentsOnly );
}

16 Mar 2008, 11:07 PM
#6
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

// Packages
if ( $shipmnt['packages'] ) {
foreach ( $shipmnt['packages'] as $pkg ) {
$package = new xmlObject ( 'Package' );
if ( $pkg['packagingType'] ) {
$code = new CombinedObject ( 'Code', $pkg['packagingType']['code'] );
$packagingType = new xmlObject ( 'PackagingType', Null, array ( $code ) );
if ( $pkg['packagingType']['description'] ) {
$description = new combinedObject ( 'Description', $pkg['packagingType']['description'] );
$packagingType->appendChild ( $description );
}
$package->appendChild ( $packagingType );
}
if ( $pkg['description'] ) {
$description = new combinedObject ( 'Description', $pkg['description'] );
$package->appendChild ( $description );
}
if ( $pkg['dimensions'] ) {
$length = new combinedObject ( 'Length', $pkg['dimensions']['length'] );
$width = new combinedObject ( 'Width', $pkg['dimensions']['width'] );
$height = new combinedObject ( 'Height', $pkg['dimensions']['height'] );
$dimensions = new xmlObject ( 'Dimensions', Null, array ( $length, $width, $height ) );
if ( $pkg['dimensions']['unitOfMeasurement'] ) {
$code = new combinedObject ( 'Code', $pkg['dimensions']['unitOfMeasurement']['code'] );
$unitOfMeasurement = new xmlObject ( 'UnitOfMeasurement', Null, array ( $code ) );
if ( $pkg['dimensions']['unitOfMeasurement']['description'] ) {
$description = new combinedObject ( 'Description', $pkg['dimensions']['unitOfMeasurement']['description'] );
$unitOfMeasurement->appendChild ( $description );
}
$dimensions->appendChild ( $unitOfMeasurement );
}
$package->appendChild ( $dimensions );
}
if ( $pkg['dimensionalWeight'] ) {
if ( $pkg['dimensionalWeight']['unitOfMeasurement'] ) {
$code = new combinedObject ( 'Code', $pkg['dimensionalWeight']['unitOfMeasurement']['code'] );
$unitOfMeasurement = new xmlObject ( 'UnitOfMeasurement', Null, array ( $code ) );
if ( $pkg['dimensionalWeight']['unitOfMeasurement']['description'] ) {
$description = new combinedObject ( 'Description', $pkg['dimensionalWeight']['unitOfMeasurement']['description'] );
$unitOfMeasurement->appendChild ( $description );
}
$dimensions->appendChild ( $unitOfMeasurement );
}
$weight = new combinedObject ( 'Weight', $pkg['dimensionalWeight']['weight'] );
$dimensionalWeight = new xmlObject ( 'DimensionalWeight', Null, array ( $unitOfMeasurement, $weight ) );
$package->appendChild ( $dimensionalWeight );
}
if ( $pkg['packageWeight'] ) {
if ( $pkg['packageWeight']['unitOfMeasurement'] ) {
$code = new combinedObject ( 'Code', $pkg['packageWeight']['unitOfMeasurement']['code'] );
$unitOfMeasurement = new xmlObject ( 'UnitOfMeasurement', Null, array ( $code ) );
if ( $pkg['packageWeight']['unitOfMeasurement']['description'] ) {
$description = new combinedObject ( 'Description', $pkg['packageWeight']['unitOfMeasurement']['description'] );
$unitOfMeasurement->appendChild ( $description );
}
$dimensions->appendChild ( $unitOfMeasurement );
}
$weight = new combinedObject ( 'Weight', $pkg['packageWeight']['weight'] );
$packageWeight = new xmlObject ( 'PackageWeight', Null, array ( $unitOfMeasurement, $weight ) );
$package->appendChild ( $packageWeight );
}
if ( $pkg['largePackageIndicator'] ) {
$largePackageIndicator = new combinedObject ( 'LargePackageIndicator', $pkg['largePackageIndicator'] );
$package->appendChild ( $largePackageIndicator );
}
if ( $pkg['referenceNumber'] ) {
$code = new combinedObject ( 'Code', $pkg['referenceNumber']['code'] );
$value = new combinedObject ( 'Value', $pkg['referenceNumber']['value'] );
$referenceNumber = new xmlObject ( 'ReferenceNumber', Null, array ( $code, $value ) );
$package->appendChild ( $referenceNumber );
}
if ( $pkg['packageServiceOptions'] ) {
$packageServiceOptions = new xmlObject ( 'PackageServiceOptions' );
if ( $pkg['packageServiceOptions']['cod'] ) {
$monetaryValue = new combinedObject ( 'MonetaryValue', $pkg['packageServiceOptions']['cod']['codAmount']['monetaryValue'] );
$codAmount = new xmlObject ( 'CODAmount', Null, array ( $monetaryValue ) );
if ( $pkg['packageServiceOptions']['cod']['codAmount']['currencyCode'] ) {
$currencyCode = new combinedObject ( 'CurrencyCode', $pkg['packageServiceOptions']['cod']['codAmount']['currencyCode'] );
$codAmount->appendChild ( $currencyCode );
}
$cod = new xmlObject ( 'COD', Null, array ( $codAmount ) );
if ( $pkg['packageServiceOptions']['cod']['codFundsCode'] ) {
$codFundsCode = new combinedObject ( 'CODFundsCode', $pkg['packageServiceOptions']['cod']['codFundsCode'] );
$cod->appendChild ( $codFundsCode );
}
if ( $pkg['packageServiceOptions']['cod']['codCode'] ) {
$codCode = new combinedObject ( 'CODCode', $pkg['packageServiceOptions']['cod']['codeCode'] );
$cod->appendChild ( $codCode );
}
if ( $pkg['packageServiceOptions']['cod']['controlNumber'] ) {
$codNumber = new combinedObject ( 'ControlNumber', $pkg['packageServiceOptions']['cod']['controlNumber'] );
$cod->appendChild ( $controlNumber );
}
$packageServiceOptions->appendChild ( $cod );
}
if ( $pkg['packageServiceOptions']['deliveryConfirmation'] ) {
$dcisType = new combinedObject ( 'DCISType', $pkg['packageServiceOptions']['deliveryConfirmation']['dcisType'] );
$deliveryConfirmation = new xmlObject ( 'DeliveryConfirmation', Null, array ( $dcisType ) );
$packageServiceOptions->appendChild ( $deliveryConfirmation );
}
if ( $pkg['packageServiceOptions']['verbalConfirmation'] ) {
if ( is_array ( $pkg['packageServiceOptions']['verbalConfirmation']['phoneNumber'] ) ) {
$phoneDialPlanNumber = new combinedObject ( 'PhoneDialPlanNumber', $pkg['packageServiceOptions']['verbalConfirmation']['phoneNumber']['phoneDialPlanNumber'] );
$phoneLineNumber = new combinedObject ( 'PhoneLineNumber', $pkg['packageServiceOptions']['verbalConfirmation']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipper']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $pkg['packageServiceOptions']['verbalConfirmation']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $pkg['packageServiceOptions']['verbalConfirmation']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $pkg['packageServiceOptions']['verbalConfirmation']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipper']['phoneNumber'] );
}
$verbalConfirmation = new xmlObject ( 'VerbalConfirmation', Null, array ( $phoneNumber ) );
if ( $pkg['packageServiceOptions']['verbalConfirmation']['name'] ) {
$name = new combinedObject ( 'Name', $pkg['packageServiceOptions']['verbalConfirmation']['name'] );
$verbalConfirmation->appendChild ( $name );
}
$packageServiceOptions->appendChild ( $verbalConfirmation );
}
$package->appendChild ( $packageServiceOptions );
}
if ( $pkg['additionalHandling'] ) {
$additionalHandling = new combinedObject ( 'AdditionalHandling', $pkg['additionalHandling'] );
$package->appendChild ( $additionalHandling );
}
$shipment->appendChild ( $package );
}
}

// ShipmentServiceOptions
if ( $shipmnt['shipmentServiceOptions'] ) {
$shipmentServiceOptions = new xmlObject ( 'shipmentServiceOptions' );
if ( $shipmnt['shipmentServiceOptions']['saturdayPickup'] ) {
$saturdayPickup = new combinedObject ( 'SaturdayPickup', $shipmnt['shipmentServiceOptions']['saturdayPickup'] );
$shipmentServiceOptions->appendChild ( $saturdayPickup );
}
if ( $shipmnt['shipmentServiceOptions']['saturdayDelivery'] ) {
$saturdayDelivery = new combinedObject ( 'SaturdayDelivery', $shipmnt['shipmentServiceOptions']['saturdayDelivery'] );
$shipmentServiceOptions->appendChild ( $saturdayDelivery );
}
if ( $shipmnt['shipmentServiceOptions']['onCallAir'] ) {
$onCallAir = new xmlObject ( 'OnCallAir' );
if ( $shipmnt['shipmentServiceOptions']['onCallAir']['schedule'] ) {
$schedule = new xmlObject ( 'Schedule' );
if ( $shipmnt['shipmentServiceOptions']['onCallAir']['schedule']['pickupDay'] ) {
$pickupDay = new combinedObject ( 'PickupDay', $shipmnt['shipmentServiceOptions']['onCallAir']['schedule']['pickupDay'] );
$schedule->appendChild ( $pickupDay );
}
if ( $shipmnt['shipmentServiceOptions']['onCallAir']['schedule']['method'] ) {
$method = new combinedObject ( 'Method', $shipmnt['shipmentServiceOptions']['onCallAir']['schedule']['method'] );
$schedule->appendChild ( $method );
}
$onCallAir->appendChild ( $schedule );
}
$shipmentServiceOptions->appendChild ( $onCallAir );
}
if ( $shipmnt['shipmentServiceOptions']['cod'] ) {
$monetaryValue = new combinedObject ( 'MonetaryValue', $shipmnt['shipmentServiceOptions']['cod']['codAmount']['monetaryValue'] );
$codAmount = new xmlObject ( 'CODAmount', Null, array ( $monetaryValue ) );
if ( $shipmnt['shipmentServiceOptions']['cod']['codAmount']['currencyCode'] ) {
$currencyCode = new combinedObject ( 'CurrencyCode', $shipmnt['shipmentServiceOptions']['cod']['codAmount']['currencyCode'] );
$codAmount->appendChild ( $currencyCode );
}
$cod = new xmlObject ( 'COD', Null, array ( $codAmount ) );
if ( $shipmnt['shipmentServiceOptions']['cod']['codFundsCode'] ) {
$codFundsCode = new combinedObject ( 'CODFundsCode', $shipmnt['shipmentServiceOptions']['cod']['codFundsCode'] );
$cod->appendChild ( $codFundsCode );
}
if ( $shipmnt['shipmentServiceOptions']['cod']['codCode'] ) {
$codCode = new combinedObject ( 'CODCode', $shipmnt['shipmentServiceOptions']['cod']['codeCode'] );
$cod->appendChild ( $codCode );
}
if ( $shipmnt['shipmentServiceOptions']['cod']['controlNumber'] ) {
$codNumber = new combinedObject ( 'ControlNumber', $shipmnt['shipmentServiceOptions']['cod']['controlNumber'] );
$cod->appendChild ( $controlNumber );
}
$shipmentServiceOptions->appendChild ( $cod );
}
$shipment->appendChild ( $shipmentServiceOptions );
}
// RateInformation
if ( $shipmnt['rateInformation'] ) {
$rateInformation = new xmlObject ( 'RateInformation' );
if ( $shipmnt['rateInformation']['negotiatedRatesIndicator'] ) {
$negotiatedRatesIndicator = new combinedObject ( 'NegotiatedRatesIndicator', $shipmnt['rateInformation']['negotiatedRatesIndicator'] );
$rateInformation->appendChild ( $negotiatedRatesIndicator );
}
$shipment->appendChild ( $rateInformation );
}
/*** RatingServiceSelectionRequest ***/
$this->xmlObject ( 'RatingServiceSelectionRequest', Null, array ( $request, $pickupType, $shipment ) );
// CustomerClassification
if ( $cClass['code'] ) {
$code = new combinedObject ( 'Code', $cClass['code'] );
$customerClassification = new xmlObject ( 'CustomerClassification', Null, array ( $code ) );
$this->appendChild ( $customerClassification );
}
}
}

?>

18 Mar 2008, 12:24 AM
#8
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

We start with:
/public_html/includes/languages/english/modules/shipping/upsfreight.php

This is an assumption that UPS /modules/shipping/upsfreight.php
is the same as FedEX, and Con Way Heavy Freight.
If this assumption is true is this correct for Zen Cart,

<?php /* This module is for use with UPS's heavy freight shipping service, weight over 150lbs., not with their regular ground shipping service. Released under the GNU General Public License */ define('MODULE_SHIPPING_UPSFREIGHT_TEXT_TITLE', 'UPS Freight'); define('MODULE_SHIPPING_UPSFREIGHT_TEXT_DESCRIPTION', 'UPS Freight transports items over 150lbs, for items under 150lbs. use UPS Ground'); define('MODULE_SHIPPING_UPSFREIGHT_TEXT_UPS', 'UPS Freight'); define('MODULE_SHIPPING_UPSFREIGHT_TEXT_ERROR_BAD_COUNTRY', 'UPS, Freight is only available to customer in the United States and Canada. <br /> all others call or email for Freight quote, see Contact Us.'); define('MODULE_SHIPPING_UPSFREIGHT_TEXT_ERROR_BAD_RESPONSE', 'UPS Freight returned an error or invalid response.'); define('MODULE_SHIPPING_UPSFREIGHT_TEXT_ERROR_DESCRIPTION', 'We\'re sorry, but an error occurred while calculating the UPS Freight shipping prices.'); define('MODULE_SHIPPING_UPSFREIGHT_TEXT_ERROR_SHIPPING_WITHIN_CA', 'We\'re sorry, but UPS Freight\'s estimator does not currently support estimates for shipping from one Canadian address to another.'); ?>
18 Mar 2008, 2:03 AM
#9
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

For
/public_html/includes/languages/english/modules/shipping/upsfreight.php

The Overrides link
/public_html/includes/languages/english/modules/shipping/
YOUR_TEMPLATE_NAME/upsfreight.php

If you do not wish to have your UPS Module lost in upgrade,
put this file in the Overrides Directory for this file.
My Template is zencart_ zen so for me it would be.
/public_html/includes/languages/english/modules/shipping/
zencart_zen/upsfreight.php
--How to do it
Create an empty Directory,
in my case called zencart_ zen upload to Server,
upload upsfreight.php file in to this Directory, in the server.

18 Mar 2008, 2:16 AM
#10
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

For
/public_html/includes/languages/english/modules/shipping/upsfreight.php

The Overrides link
/public_html/includes/languages/english/modules/shipping/
YOUR_TEMPLATE_NAME/upsfreight.php

If you do not wish to have your UPS Module lost in upgrade,
put this file in the Overrides Directory for this file.
My Template is zencart_ zen so for me it would be.

/public_html/includes/languages/english/modules/shipping/
zencart_zen/upsfreight.php

--How to do it
Create an empty Directory,
in my case called zencart_ zen upload to Server,
upload upsfreight.php file in to this Directory, in the server.

This is for info. only.

18 Mar 2008, 2:49 PM
#11
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Relentless,

Could you post the .php files in the downloads section? Copying/pasting from the browser is inserted random spaces in the code for some reason.

Thanks.

18 Mar 2008, 9:09 PM
#12
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Ref: Question post the PHP files to the Downloads section.

This is not a Module, it is in the Development stage.
The best solution would be to Download the tar.gz zip at this link
http://linux.softpedia.com/get/Internet/HTTP-WWW-/UPS-XML-RPC-Interface-33044.shtml

It is only one file, see the PHP page 1 this thread, it is the same,
remove the GNU General Public License v3 text, for brevity,
as I have done with the same PHP code on page 1 this thread,
so we will all be on the same file line.
You should use a PHP editor, not an html editor.

20 Mar 2008, 1:41 AM
#13
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Ref: chadderuski

If you are referring to, the N in DESCRIPTIO N,
in your PHP Editor correct this.
define('MODULE_SHIPPING_UPSFREIGHT_TEXT_DESCRIPTIO N', 'UPS Freight

New: Next the Function file,
/public_html/includes/modules/shipping/YOUR_TEMPLATE_NAME/upsfreight.php

22 Mar 2008, 1:47 AM
#14
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

One Question see below

UPS XML-RPC Interface is a simple XML-RPC
service for connecting to UPS for shipping estimates.
UPS XML-RPC Interface is written in PHP,
but can be accessed by any program
that can communicate with XML-RPC.

In your PHP application you'll need a function to make XML-RPC requests.
I've provided an example below.
Any programming language that can make XML-RPC requests
can make requests of the UPS XML-RPC interface in a similar way.

function remoteRequest ( $server, $method, $params ) {
$req = xmlrpc_encode_request ( $method, $params );
$headers = array (
'Content-Type: text/xml',
'Content-Length: ' . strlen ( $req )
);
$ch = curl_init ( "http://$server/" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, True );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 600 );
set_time_limit ( 600 );
$resp = curl_exec ( $ch );
set_time_limit ( 30 );
curl_close ( $ch );
return xmlrpc_decode ( $resp );
}

The structure of the XML-RPC request,
is very similar to the XML requests documented in the
'UPS OnLine Tools Rates and Service Selection Developers Guide'.

$resp = remoteRequest ( 'ups', 'ratingServiceSelectionRequest', $upsParams );

From your PHP application you can connect to a server,
'ups', and run the function, 'ratingServiceSelectionRequest',
with the options defined in an array, $upsParams.
The result will be returned as the $resp array.

/* Question for Rate quote only is this correct, or add, $method,*/

$resp = remoteRequest ( 'ups', 'ratingServiceSelectionRequest', $upsParams );
{$req = xmlrpc_encode_request ( $method, $params );
$headers = array (
'Content-Type: text/xml',
'Content-Length: ' . strlen ( $req )
);
$ch = curl_init ( "http://$server/" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, True );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 600 );
set_time_limit ( 600 );
$resp = curl_exec ( $ch );
set_time_limit ( 30 );
curl_close ( $ch );
return xmlrpc_decode ( $resp );
}

22 Mar 2008, 10:14 PM
#15
relentless avatar

relentless

New Zenner

Join Date:
Sep 2007
Posts:
56
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Sorry for my confusion lets try it again.

In your PHP application you'll need a function to make XML-RPC requests.
I've provided an example below.
Any programming language that can make XML-RPC requests
can make requests of the UPS XML-RPC interface in a similar way.

function remoteRequest ( $server, $method, $params ) {
$req = xmlrpc_encode_request ( $method, $params );
$headers = array (
'Content-Type: text/xml',
'Content-Length: ' . strlen ( $req )
);
$ch = curl_init ( "http://$server/" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, True );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 600 );
set_time_limit ( 600 );
$resp = curl_exec ( $ch );
set_time_limit ( 30 );
curl_close ( $ch );
return xmlrpc_decode ( $resp );
}

1]From your PHP application you can connect to a server, 'ups',
2]and run the function, 'ratingServiceSelectionRequest',
3]with the options defined in an array, $upsParams.

4]$resp = remoteRequest ( 'ups', 'ratingServiceSelectionRequest', $upsParams );

1]$server ='ups';
2]$method ='ratingServiceSelectionRequest';
3]$params = $upsParams; AND $upsParams; must previously have been set to something appropriate.

When the function 4]'ratingServiceSelectionRequest', runs,
the result will be returned as the
$resp array
with the Freight quote cost, and your options cost[$upsParams]
if options are selected.

Definition: a function is simply a set of program statements
which perform a specific task,
and which can be "called",
or executed, from anywhere in your program

functions like this are put at the bottom of the pHp page.
$resp = remoteRequest ( 'ups', 'ratingServiceSelectionRequest', $upsParams

12 Jan 2011, 11:10 PM
#16
cycochuck avatar

cycochuck

New Zenner

Join Date:
Jan 2010
Posts:
42
Plugin Contributions:
0

Re: UPS Heavy Freight Module UPS Freight over 150 lbs.

Has anyone got this working? I would be very interested in this if they have.