Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


June 1997

Getting Started with Microsoft Merchant Server


RSS
Subscribe to Windows IT Pro | See More Site Server Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Designing a Merchant Server Page
Suppose you are writing a page to display items of a selected brand that are available from your store. You include your common header and footer, common images (such as your logo on the page), and product images. The page looks like Listing 1. Let's go over this code.

First, pgen inserts the header file by finding header.html and inserting it in the include file. The Merchant tag shown in callout A is a SQL Server directive to get information from your database. The fetchrows tag grabs data from your SQL Server database and places it into the productinfo object. You can use the powerful fetchrows tag in several ways. The syntactical format for using fetchrows is:
[fetchrows nameForReference valRQuery valRArg1...valRArgN]

Using this syntax, nameForReference is the variable name that will contain the returned data result set, and valRQuery is the reference name of the query in the SQL data table (the table name is defined in the Registry; the ADD STORE feature in the Control Panel applet created the table name for you if you used ADD STORE). The valRArg1...valRArgN terms are arguments Merchant Server will pass to the SQL Server in the query.

In your database, in the SQL table that you defined (in the Registry key Database, Value Db_table_sql) to store predefined SQL statements, the name column contains the reference name for the query in the sql_text column. For example, the name selected-brand in the SQL table refers to select * from me_brand where brand_id = convert(numeric,:1) in the sql_text column.

In this example, you can use
[fetchrows brands "selected-brand" 2]

to call the brands object, which contains all the information from the me_brand table, where brand_id = 2. To reference variables passed in the SQL table, use the :N argument in the table (where N is the argument being passed). Use this variable for each argument you want to send, incrementing by one for each argument you want Merchant Server to process (e.g., :1, :2, :3). Use this variable only in the sql_text entry in your sql table. Also note that the Merchant System sends all variables using the fetchrows tag as text, so you have to use the convert(numeric,:1) function. You won't need that function if you want to match a text variable.

Now that I've explained the fetchrows tag, I need to talk about args.brand_id in the example. The args object contains all the variables from the page that called this page and posted values to this page. If you were on the previous page and you need to send the brand_id value to this page, you can use the Merchant link tag to send the value easily. For the link to the next page, you can write
[form "thebrands.html" brand_id=brands]
<select name="brands">

[option "NCR"] 1

[option "Compaq"] 2
</select>
[/form]

Or you can write
[link "thebrands.html" brand_
id=2]Go to brands page for Brand 2[/link]

This directive not only sends you to the page "thebrands.html," but it also includes the value for brand_id.

The args.object and the var.object differ in that a posting form passes the args.object, and the Merchant let tag creates the var.object. For example,
[let cool_brand 2]

assigns the value 2 to var.cool.brand. When tagged such as

Sally uses brand [value var.cool_brand].

pgen outputs

Sally uses brand 2.

Now, back to the code. The directive [if brandinfo.img_file !="none"] applies a bit of logic to the code. In this example, if brandinfo.img_file is not equal to "none," Merchant Server executes the first part of the if statement:
<IMG SRC="[simg]/products/[value brandinfo.img_file]" BORDER=0>

After pgen gets through with this line, it looks like
<IMG SRC="imagepath/products/
cool_brand.gif" BORDER=0>

Merchant Server is doing two things here. First, it is expanding the simg tag that represents the path to your server's shared image directory. Second, it is expanding value brandinfo.img_file to equal the value stored in the brandinfo recordset item named img_file. In this case, the value is the name of the corresponding image file for this brand.

Notice the code at B in Listing 1. This code uses the xlink directive, which has syntactical format
[xlink action argName1=value
RArg1...argNameN=valueRArgN]

The xlink directive is similar to the link tag with an important difference. When you click the output text between [xlink] and [/xlink], Merchant Server performs an action instead of going to a page directly. In this case, that action is order.additem, and I am sending that action a named argument--in this case, sku=productinfo.sku. This code will generate a list of products, each with a unique xlink to the order.additem action, adding the product selected to the order. Merchant Server will execute whatever the action order.additem defines in the Registry. This function is handy, especially if you perform the same functions frequently. In this example, the argument passed is the sku of the product you want to add to the current order.

The eachrow tag syntax,
[eachrow NameForReference valueRStart valueREnd]

tells pgen to take the object that NameForReference references (starting at row 1 or a select row range, hence valueRStart valueREnd), usually a recordset of some type, and flip through each row of data it contains, one at a time, until the end of the recordset is reached. Think of this process as a loop for your data, or if you are familiar with DAO, a Do loop for your recordset with a built-in MoveNext command. This example displays a list of products.

At the end of B in Listing 1, you see the money value display tag:
[money productinfo.list_price]

The syntactical format for this tag is
[money valueRAmount valueRLocale valueRScale]

You use this tag for converting a value (valueRAmount) into money. Using the optional arguments valueRLocale and valueRScale, you can override the Registry defaults for money location and scale to that of any country that Merchant Server supports. Although using the Merchant Server directives might seem complicated at first, you'll soon catch on. The results are worth the initial effort. Screen 1 is an example of a page created with Merchant Server.

From Mom and Pop to a Mall
Merchant System is a scalable product. You can use it to start a small store, and it will grow with you, with almost no growing pains. For example, my mother can use Merchant Server to display her needlepoint patterns in an online craft store--a small business. This exposure will be great for her company. At the rate she generates patterns, she'll want to continually update the online catalog to keep her customers interested. When she makes it as big as Trudy & Jenny's Stitch Patch, she can easily migrate to a distributed system to keep the Web site running smoothly, without delays. She can even open a virtual mall and rent space to anyone--from Rhoda next door to Crabtree and Evelyn. The possibilities are virtually endless (pun intended). Best of all, Merchant Server is easy to maintain. Once it's up and running, it's up to stay. Merchant Server's stability is a good thing: I hate to think what would happen if my mother's server went down.

End of Article

   Previous  1  2  [3]  Next  


Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...


Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement