Microsoft KB Archive/172662

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 11:30, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Article ID: 172662

Article Last Modified on 9/30/2003


  • Microsoft Commerce Server 2.0

This article was previously published under Q172662


Microsoft Commerce Server 2.0 creates a 26 character order ID for each shopper's order. This order ID is a Globally Unique Identifier (GUID) generated by the Windows NT system, and is difficult for hackers to guess. However, some merchants have a requirement to create and save a shorter order ID. This article describes ways to generate shorter order IDs.


Put Your Own Format Order ID on the Order Form When It Is Initially Created

One way to create shorter IDs is to put your own format order ID onto the order form when it is initially created. When the order pipeline runs normally, no order_id name/value-pair exists, so Commerce Server creates one. If the order_id name/value-pair already exists, Commerce Server does not attempt to overwrite it.

To do this, perform the following steps:

  1. Create a database table that holds the last assigned order_id. Create a stored procedure that fetches the next order ID to be assigned, and remembers it as the last assigned order_id. For example, the following Microsoft SQL Server script does this for the ClockPed store:

       * Create a table to hold the last assigned order number. Seed it at 100.
       drop table ClockPed_ordernumber
       create table ClockPed_ordernumber(
          order_id int)
       INSERT ClockPed_ordernumber VALUES (100)
       drop proc sp_CPgetorderid
       CREATE PROCEDURE sp_CPgetorderid
       @ide int = 0
       UPDATE ClockPed_ordernumber
       SET next_order_id = next_order_id+1 , @ide = next_order_id
       SELECT @ide order_id
  2. Update the xt_orderform_additem.asp page to invoke the stored procedure and save the order_id onto newly created order forms. Again, in ClockPed, this would be something like the following:

       if IsEmpty(orderForm) then
       REM -- create a new orderform:
       set orderForm = Server.CreateObject("Commerce.OrderForm")
       orderForm.shopper_id = shopperID
       orderForm.date_created = Now
       REM Retrieve the next available order_id number from the database
       on error resume next
       set o_id = MSCSDataSource.Execute("EXEC sp_CPgetorderid")(0)
       on error goto 0
       if Not IsEmpty(o_id) then
          orderForm.order_id = o_id.order_id
       end if
       REM -- add item to orderform:
       set item = orderForm.AddItem(CStr(product_sku), product_qty, 0)

Create a New Column in the Database Table that Holds the Order Information

If you want a shorter order_id for the convenience of a shopper, you can create a new identity column in the database table that holds the order information. This column would be incremented automatically by SQL Server, whenever an order is saved to the database. You can then retrieve the identity column value that corresponds to a given order_id generated by Commerce Server, and display it to the shopper on your purchase confirmed page.

To do this, perform the following steps:

  1. Alter your receipt table to contain a new identity column. The following SQL Server script alters the vc_receipt table of the Volcano Coffee store: delete from vc_receipt go alter table vc_receipt add NewOrder_ID int identity
  2. Modify the Confirmed.asp file to include the following:

       <% OrderID = Request("order_id")
       set test = DataSource.Execute("select neworder_id from vc_receipt where
       order_id = :1",  OrderID)(0) %>
       <TR><TD colspan=3>For future reference, please make a note of the
       tracking number for this order.</TD></TR>
       <TR><TD> </TD></TR>
       <TR><TD><img src="<% =Application("Images") %>images/trackno.gif"
       valign=bottom></td><td  valign=top><b>
       <% = test.neworder_id %>
       </b></td></TD><td> </td></TR>

Additional query words: orderform orderforms Merchant

Keywords: kbhowto kbinfo kbprogramming kbusage KB172662