Microsoft KB Archive/172662: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "<" to "<")
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">  &lt;% OrderID = Request(&quot;order_id&quot;)
<pre class="codesample">  <% OrderID = Request(&quot;order_id&quot;)
   set test = DataSource.Execute(&quot;select neworder_id from vc_receipt where
   set test = DataSource.Execute(&quot;select neworder_id from vc_receipt where
   order_id = :1&quot;,  OrderID)(0) %&gt;
   order_id = :1&quot;,  OrderID)(0) %&gt;


   &lt;TR&gt;&lt;TD colspan=3&gt;For future reference, please make a note of the
   <TR&gt;<TD colspan=3&gt;For future reference, please make a note of the
   tracking number for this order.&lt;/TD&gt;&lt;/TR&gt;
   tracking number for this order.</TD&gt;</TR&gt;
   &lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
   <TR&gt;<TD&gt;&amp;nbsp;</TD&gt;</TR&gt;
   &lt;TR&gt;&lt;TD&gt;&lt;img src=&quot;&lt;% =Application(&quot;Images&quot;) %&gt;images/trackno.gif&quot;
   <TR&gt;<TD&gt;<img src=&quot;<% =Application(&quot;Images&quot;) %&gt;images/trackno.gif&quot;
   valign=bottom&gt;&lt;/td&gt;&lt;td  valign=top&gt;&lt;b&gt;
   valign=bottom&gt;</td&gt;<td  valign=top&gt;<b&gt;
   &lt;% = test.neworder_id %&gt;
   <% = test.neworder_id %&gt;
   &lt;/b&gt;&lt;/td&gt;&lt;/TD&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/TR&gt;
   </b&gt;</td&gt;</TD&gt;<td&gt;&amp;nbsp;</td&gt;</TR&gt;
                         </pre></li></ol>
                         </pre></li></ol>



Revision as of 16:25, 20 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:

  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
       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
                            
  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
       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:

  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>&nbsp;</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>&nbsp;</td></TR>
                            



Additional query words: orderform orderforms Merchant

Keywords: kbhowto kbinfo kbprogramming kbusage KB172662