Chapter 24 Revisited: Dynamic Shipping Costs

 by Tom Muck

Chapter 24 of Dreamweaver UltraDev 4: The Complete Reference demonstrated the use of the UltraDev Shopping Cart extension from Powerclimb. There are a few details that were left out to keep the implementation as simple as possible across 4 server languages. This tutorial will pick up on that chapter using the same files and database.

One of the details that we've been getting requests for is dynamic shipping. On the cart display page, there is a shipping calculation added that is simply a standard $4.00 per pound shipping cost. This will need to be changed to allow for the dynamic shipping code.

Shipping can be done in a variety of ways. You can charge by the weight, number of items, or location. Also, there could be different types of shipping options that the user can choose, such as Standard, Overnight, 2-day, or Pony Express ;-). The sample database already contains a shipping method table, but it wasn't implemented in the book. We'll take care of that now.

The idea is to have your shipping types and costs stored in the database so that if they change in the future you need to only update them in the database and nowhere else. The ShippingMethods table contains the following entries:

ShippingMethodID

ShippingCostPerPound

ShippingMethod

1

$4.00

Standard

2

$8.00

Overnight

3

$6.00

2nd day Air

4

$4.00

UPS

As you can see, if the rate goes up, or if you add another method, you can do it easily within the database itself and not worry that your pages will have to be changed.

Next >>>