Adding Items to the Shopping Basket
Adding products to the user's shopping cart takes a few extra parameters (additional items of information that the Engine needs in order to complete its task). Obviously, you need to tell the Engine what product you are selecting, as well as its price, quantity, shipping charge/weight, description, etc.
The Engine recognizes a number of "fields" (bits of information associated with an item):
There are a number of ways to invoke the Engine. In order to give you maximum flexibility, we allow the ability to perform most of the Engine's functions from within a FORM as well as a stand-alone URL. In a FORM statement, you can have the user select multiple products with a single submission as well as specify quantities at the time of selection. With a URL statement, you can create clickable graphics which add items to a basket or go to the check out.
In each case, the method of sending information is slightly different as a result of the different references.
These commands are sent to the Engine in one of two ways:
<A HREF="http://order.icorp.net/mpr/mo?add+c_sample+i_10+u_1.95+q_1+n_Bob's_Bar-B-Que_Sauce ...
(The actual commands & options are outlined in detail later)
The static portion of the URL is: http://order.icorp.net/mpr/mo
with a question mark "?" separating the URL from the commands. The first command is the function (in this case, "add" meaning to add the specified product to the user's shopping basket), followed by the Vendor ID, and then the fields identifying the item.Note that in the above example, the fields of information associated with an item are "encoded" into a single line in a special format. Once you understand how to use the tokens, you can immediately get your online store up and running.
The fields are referenced in the format of:
token character_field value
(a single lowercase character, immediately followed by an underscore, immediately followed by your data)
and each field is separated on the command line by a plus "+" sign.NOTE: There should be no spaces anywhere in the URL or else it won't work. If you need to specify a space in the field value, use an understore "_" character and the engine will convert it to a space later.
The token characters are identified as follows:
- c - Vendor ID (configuration name)
- i - Item Number
- u - Unit Cost
- q - Quantity
- n - Item Name
- s - Item Style
- f - Item Freight
- v - Vendor ID (associated with each item - not required, only for "malls")
<FORM METHOD="post" ACTION="http://order.icorp.net/mpr/mo">
<INPUT TYPE="hidden" NAME="c_sample" VALUE="1">
<INPUT TYPE="hidden" NAME="function" VALUE="add">
...
<INPUT TYPE="hidden" NAME="function" VALUE="add">
<INPUT TYPE="hidden" NAME="item" VALUE="10">
<INPUT NAME="iqty" VALUE="0">
<INPUT TYPE="hidden" NAME="iunit" VALUE="1.95">
<INPUT TYPE="hidden" NAME="iname" VALUE="Bob's Bar-B-Que Sauce">
...
<INPUT TYPE="submit" VALUE="Add Items to my Basket">
</FORM>
As you can see, the method of specifying field values (information on your item) is slightly different when using an HTML FORM. With the exception of the Vendor ID, you spell-out the name of the fields in separate <INPUT ... > statements.In the above example, the first two fields specify the Vendor ID and function respectively. These are required. In the second set of fields, we specify information on the item. In this case, we've made the quantity field user-selectable - the idea being we're presenting a list of products. If the user changes the quantity from 0 to 1, it indicates they're ordering/adding the particular item. Otherwise, any item with a quantity of 0 will be ignored.
The fields are referenced in the format of:
<INPUT TYPE="hidden" NAME="field name" VALUE="field value">
The field names are identified as follows:
- item - Item Number
- iqty - Quantity
- iunit - Unit Cost
- iname - Item Name
- istyle - Item Style
- ifreight - Item Freight
- ivendor - Vendor ID (associated with each item - not required, only for "malls")
In following sections of the tutorial, you'll find numerous examples of these HTML statements and their proper usage.