The item display page is central to the Web Store in displaying detailed content information about each item. You can reach this page in a number of different ways either directly off the homepage where the specials point at this URL or

Url example: Item.wws?sku=WCONNECT

hit with the following URL linked from the homepage directly:

http://localhost/wwstore/item.wws?sku=WEBSTORE

This page is also called from several other locations. You can get here through the category lists as well.

To display an item very little code runs on the server. Basically there's code that loads the cItem business object

FUNCTION Item
PRIVATE loItem,oItem, pcSKU

*** Add Cookie Check session var - in case people jump directly
*** to an item display page as their first page
Session.SetSessionVar("CookiesOn","True")

*** Create an Item object
loItem = CREATE([WWS_CLASS_ITEM])
#IF WWSTORE_USE_SQL_TABLES
loItem.SetSQLObject(Server.owwStoreSQL)
#ENDIF

pcSKU = UPPER(Request.QueryString("Sku"))

*** Try to retrieve the requested item by sku
IF EMPTY(pcSKU) OR ;
   !loItem.GetItemBySku(pcSku)
   THIS.ErrorMsg("Invalid Item","Invalid SKU. This item is unavailable at this time")
   RETURN
ENDIF

*** Assign to a PRIVATE variable
oItem = loItem.oData

*** Do we return XML?
IF THIS.nResultMode = 2
  THIS.ReturnObjectXML(oItem,,,",regtext,regpass,saveemail")
  RETURN
ENDIF

*** Render the external HTML template
Response.ExpandTemplate( Request.GetPhysicalPath() )
ENDFUNC
* wwStore :: Item


Super simple right? The HTML then uses the oItem reference to display the item information:

<%= oItem.Descript %>
<%= DisplayMemo( oItem.lDescript) %>

Note the use of DisplayMemo to properly format the text from the inventory table memo field. Display memo basically inserts <p> and <br> tags for line breaks.

The following expression actually checks the stock count to see if items are available - if not it displays a message that the item is sold out and also doesn't put a submit button onto the form. The following puts up the message:

<%= IIF(oItem.Physical and oItem.Stock < 1,[<table height="35"><tr><td bgcolor="LightGrey" style="font:bold bold Verdana 240pt;color:DarkRed">Sorry, this item is Sold Out... </td></tr></table>],[]) %>

As you can see you can do some sophisticated logic as part of the display page.

You can change the HTML template as you see fit for your own item displays of course. For example you can add custom fields to the item table and display those fields in addition to the ones that are stock. Or you can use the XML field to hold some custom properties and peel those out with Extract():

<%= EXTRACT(oItem.XML,"<customproperty>","</customproperty>") %>



Next: Adding an item to the Shopping Cart


Last Updated: 06/02/03 | Send topic feedback