Microsoft KB Archive/172662: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - "&" to "&") |
||
(One intermediate revision by the same user not shown) | |||
Line 86: | Line 86: | ||
<pre class="codesample"> if IsEmpty(orderForm) then | <pre class="codesample"> if IsEmpty(orderForm) then | ||
REM -- create a new orderform: | REM -- create a new orderform: | ||
set orderForm = Server.CreateObject( | set orderForm = Server.CreateObject("Commerce.OrderForm") | ||
orderForm.shopper_id = shopperID | orderForm.shopper_id = shopperID | ||
orderForm.date_created = Now | orderForm.date_created = Now | ||
Line 93: | Line 93: | ||
REM | REM | ||
on error resume next | on error resume next | ||
set o_id = MSCSDataSource.Execute( | set o_id = MSCSDataSource.Execute("EXEC sp_CPgetorderid")(0) | ||
on error goto 0 | on error goto 0 | ||
if Not IsEmpty(o_id) then | if Not IsEmpty(o_id) then | ||
Line 111: | Line 111: | ||
<li>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</li> | <li>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</li> | ||
<li><p>Modify the Confirmed.asp file to include the following:</p> | <li><p>Modify the Confirmed.asp file to include the following:</p> | ||
<pre class="codesample"> <% OrderID = Request( | <pre class="codesample"> <% OrderID = Request("order_id") | ||
set test = DataSource.Execute( | set test = DataSource.Execute("select neworder_id from vc_receipt where | ||
order_id = :1 | order_id = :1", OrderID)(0) %> | ||
<TR><TD colspan=3>For future reference, please make a note of the | <TR><TD colspan=3>For future reference, please make a note of the | ||
tracking number for this order.</TD></TR> | tracking number for this order.</TD></TR> | ||
<TR><TD>& | <TR><TD> </TD></TR> | ||
<TR><TD><img src= | <TR><TD><img src="<% =Application("Images") %>images/trackno.gif" | ||
valign=bottom></td><td valign=top><b> | valign=bottom></td><td valign=top><b> | ||
<% = test.neworder_id %> | <% = test.neworder_id %> | ||
</b></td></TD><td>& | </b></td></TD><td> </td></TR> | ||
</pre></li></ol> | </pre></li></ol> | ||
Latest revision as of 12:30, 21 July 2020
Article ID: 172662
Article Last Modified on 9/30/2003
APPLIES TO
- Microsoft Commerce Server 2.0
This article was previously published under Q172662
SUMMARY
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.
MORE INFORMATION
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:
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 go create table ClockPed_ordernumber( order_id int) go INSERT ClockPed_ordernumber VALUES (100) go drop proc sp_CPgetorderid go CREATE PROCEDURE sp_CPgetorderid @ide int = 0 AS UPDATE ClockPed_ordernumber SET next_order_id = next_order_id+1 , @ide = next_order_id SELECT @ide order_id go
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 REM 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:
- 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
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