Regardless of how simple your store is, you'll likely will want to change the way shipping and tax calculations work in the store. West Wind uses very simple shipping calculations that are flat fee based which is appropriate for our mostly software based distributions. But most businesses probably actually have to perform real shipping calculations to figure out pricing. Shipping affects how the shopping cart displays as well as the final saved invoice.

The cShippingBehavior class handles customizations for shipping. You simply create a new instance of that class, and implement its Calculate method which should return the shipping total for the order. You then set the Invoice's cShippingBehaviorClass to the name of the class you created (making sure the class is loaded with SET CLASSLIB). Tax behavior is handled exactly the same way.

For example, here is what cwwTaxBehavior class does to calculate General Excise Tax for orders placed from Hawaii:

LPARAMETERS oinv

*** Handle Hawaii General Excise Taxes
IF oInv.oCustomer.oData.State = "HI"
   RETURN ROUND(THIS.nSubTotal * 0.04,2)
ENDIF

RETURN 0

You get an oInvoice object passed to you as a parameter, which provides you with all of the invoice, customer and lineitem data to use in your calculation.

Both shipping and Tax behavior are fired in the cInvoice::InvoiceTotal() method which writes the results in the appropriate fields.

Implementing a more complex shipping scheme in the HTML interface is a little more difficult, because you're going to have to build the UI for this operation yourself. Most likely you'll need to change the ShoppingCart.wws page to provide the shipping options and you'll have to add the appropriate code to handle these options in the ShoppingCart method. Depending on how complex your shipping user interface is this may as easy as changing or adding to the radio buttons on the existing form to entirely removing the Shopping Cart's shipping calculation view and putting it onto a seperate form.


Last Updated: 5/31/2003 | Send topic feedback