| West Wind Web Store |
| The Item Display Page |
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
<%= oItem.Descript %> <%= DisplayMemo( oItem.lDescript) %>
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>],[]) %>
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>") %>
Last Updated: 06/02/03 |
Send topic feedback