Encapsulating the Shopping Cart in a Custom Tag

Although the version of StoreCart.cfm in Listing 22.4 works just fine, the code itself is a bit messy. It contains quite a few list functions, which don’t necessarily have to do with the conceptual problem at hand (the user’s cart). Worse, other templates that need to refer to the user’s cart (such as the Checkout template) must use nearly all the same list functions over again, resulting in quite a bit of code for you to maintain.

You will learn about Custom Tags in Chapter 25, “Creating Custom Tags,” in Vol. 2, Application Development. This early example is rather simple, but if you find it confusing, read ahead to Chapter 25.

Building <cf_ShoppingCart>

The code in Listing 22.5 creates a Custom ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.