Posts Tagged ‘UPS’

Using the UPS Shipping & Rating API with Coldfusion

Friday, December 11th, 2009

Just a heads up that this is a fairly long article and makes several assumptions about your application. Using the UPS API is fairly easy, but there are several variables that are required for the api to work successfully.

I’ll be making several assumptions here.  First and foremost that you are looking to implement the UPS shipping and rating API for ecommerce.  Second that you have a database set up with a table named ’shipping_tbl’ that includes column names ‘package_weight’, ‘package_width’, ‘package_length’, and ‘package_height’.  And that these values are in some way related to the products whose dimensions and weight they represent.  As well as other assumptions like how we store our cart data that will be further explained later.

Let’s start out with our HTML.  This is the HTML that represents your cart, which is where I assume you are showing the shipping rate for whatever packages are being sold.  We’ll pretend there’s a cart here.  I’m, however, only going to show the code for the output of the shipping rate.  So it is as follows.

The HTML (Output of shipping data)

<!---set our shipping rate--->
<cfset VARIABLES.shippingrate = "">

<span class=”shippingrate”>
	<!---output our shipping rate to the page--->
	<cfoutput>#dollarformat(VARIABLES.shippingrate)#</cfoutput>
</span>

(more…)