1. Before testing that the new system is working for tax and shipping charges, use the OrderTest.aspx page to check that old orders are unaffected. The information retrieved for an old order should be unaffected because the data is unchanged.
2. Place a new order, preferably with a customer in the United States/Canada shipping region (as this is currently the only region where tax is applied). Notice that on the checkout page you must select a shipping option, as shown in Figure 13-4.
C H A P T E R 1 3 ■ A D V A N C E D C U S T O M E R O R D E R S 513
Figure 13-4. Selecting a shipping region
3. After placing the order, check the OrderID of the order in the database and then retrieve the order using OrderTest.aspx. The result is shown in Figure 13-5.
Figure 13-5.Order including tax and shipping charges
How It Works: Testing Tax and Shipping Charges
In this chapter leading up to this example, you’ve pretty much examined how the tax and shipping charges operate, but let’s recap.
First, the customer is required to select a shipping region for their address. Without this shipping region being selected, visitors cannot place orders, because they cannot select a shipping option. When a visitor places an order, the shipping region selected is attached to the order in the Orders table. The tax requirement for the order is also attached, although this requires no user input (and is currently selected using a very simple algorithm, although this wouldn’t be difficult to change).
Next, when you use the CommerceLibOrderInfo class, the tax and shipping is automatically taken into account in both the total cost and text representation of the order.
C H A P T E R 1 3 ■ A D V A N C E D C U S T O M E R O R D E R S 515
Further Development
There are several ways to proceed from here. Perhaps the first might be to add an administra- tion system for tax and shipping options. This hasn’t been implemented here partly because it would be trivial given the experience you’ve had so far in this book, and partly because the techniques laid out here are more of a template for development then a fully developed way of doing things. There are so many options to choose from for both tax and shipping calculations that only the basics are discussed here.
Hooking into online services for tax and shipping cost calculations is an attractive option;
for shipping services, this is very much a possibility. In fact, the services offered by shipping companies such as FedEx use a similar way of going about things as the credit card gateway companies we’ll look at later in this book. Much of the code you’d have to write to access these services will be very similar to that for credit card processing, although of course you’ll have to adapt it to get the specifics right. Sadly, there may be more major changes required, such as adding weights and dimensions to products, but that very much depends on what products you are selling. For items in the BalloonShop catalog, many products are lighter than air, so shipping could be very cheap.
Summary
In this chapter, you’ve extended the BalloonShop site to enable customers to place orders using all the new data and techniques introduced in Chapter 12. Much of the modification made in this chapter lays the groundwork for the order pipeline to be used in the rest of this book. You’ve also included a quick way to examine customer orders, although this is by no means a fully fleshed out administration tool—that will come later.
You also implemented a simple system for adding tax and shipping charges to orders. This system is far from being a universal solution, but it works and it’s simple. More importantly, the techniques can easily be built on to introduce more complex algorithms and user interac- tion to select tax and shipping options and price the order accordingly.
From the next chapter onward, you’ll be expanding on the customer ordering system even more by starting to develop a professional order pipeline for order processing.
517
■ ■ ■
C H A P T E R 1 4
Order Pipeline
In this and the next chapter, you’ll build your own order-processing pipeline that deals with credit card authorization, stock checking, shipping, sending email notifications, and so on. In fact, we’ll leave the credit card processing specifics until Chapter 16, but we’ll show you where this process fits in before then.
Order pipeline functionality is an extremely useful capability for an e-commerce site because it allows you to track orders at every stage in the process, and provides auditing infor- mation that you can refer to at a later date or if something goes wrong during the order processing.
You can do all this without relying on a third party’s accounting system, which also can reduce costs. The first section of this chapter discusses what we actually mean by an order pipeline and the specifics that apply to the BalloonShop application.
Such a system can be implemented in various ways, and many people recommend that you use a transactional system such as MTS (Microsoft Transaction Server), or COM+ (Component Object Model+) in more recent operating systems. However, this method adds its own compli- cations and doesn’t give you that much that you can’t achieve using standard .NET assemblies.
Although it’s possible to create COM+ components using .NET, the code implementation is more complicated, and debugging code can be tricky. For this reason, we’ll stick with the .NET platform here, which has the added advantage that it makes code easier to understand and debug. The bulk of this chapter deals with constructing such a system, which also involves a small modification of the way things currently work and some additions to the database you’ve been using. However, the code in this chapter isn’t much more complicated than the code you’ve already been using. The real challenges are in the design of the system.
By the end of Chapter 15, you’ll be able to follow the progress of customer orders as they pass through various stages of the order pipeline. Although no real credit card processing takes place, you’ll end up with a fairly complete system, including a new administration web page that can be used by suppliers to confirm that they have items in stock and to confirm that orders have been shipped. To start with, however, you need a bit more background about what we are actually trying to achieve.