Hack 75 Upsell Your Customers

figs/moderate.gif figs/hack75.gif

Use the return variable to provide a list of items in which a customer might also be interested.

Although you can use IPN to provide an order summary [Hack #74], you're missing a sales opportunity if you don't use this page to advertise your other products, a technique known as upselling. For instance, say you're selling bicycle parts and someone comes along and buys a bottom bracket from your web site. Using this technique, your web site would then present this customer with a small ad listing some of the cranksets, pedals, and derailleurs you sell. It's easy to do, and it works better than you might expect.

7.15.1 The Return Page's Job

The return page is the page you show your customers once they are done paying for an item. To help you upsell your customers, this page has several jobs to do:

  • Retrieve information about the products purchased. In order to use this hack, you also need to insert cart details into a database [Hack #83] (or something like it) to keep a running record of purchases your customers have made.

  • Consult your sales database to find out what other buyers of this item have purchased. The heavy lifting in this hack comes from a single database query that is used to search the contents of the database table [Hack #74] to find a list of products that have been purchased by other customers.

  • Display a link and brief description for each. [Hack #55] shows how to link directly to the other product's details page so that customers can continue shopping if they choose.

7.15.2 The Code

Here's the ASP code that does it all:

<% 'Find the number of the item just purchased

Dim item_number

Item_number = Request.Form("item_number") %>

'Find products purchased by other buyers

connStore = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=


set rsProducts = Server.CreateObject("ADODB.Recordset")

rsProducts.ActiveConnection = connStore

rsProducts.Source = "SELECT DISTINCT item_number FROM tblOrderDetails 

                WHERE (payer_email IN (SELECT payer_email FROM tblOrderDetails WHERE 

(txtItemNumber = 'item_number')))"

rsProducts.Open( )


<% If Not rsProducts.EOF Or Not rsProducts.BOF Then 'it exists %>


'While recordset still has products, loop code

While NOT rsProducts.EOF


<a href="http://yoursite.com/product_detail.asp?item_number=<%=rsProducts

("item_number)%">Link Text Here</a><br>


'Move to next record

rsProducts.MoveNext( )



<% End If %>

See the "Database Coding and Platform Choices" section of the Preface for the additional information needed to put this SQL statement to work with this and the other hacks in this book.

7.15.3 Running the Code

Simply save this file in a public folder on your web server, and then set your return page to the URL of the page [Hack #85] . When a customer pays, this code looks up the product that was just purchased and uses a SQL statement to look up past purchases of this product to see what other products those customers purchased along with it.