<% UC_CartColNames=Array("ProductID","Quantity","Name","Size","Colour","Price","Total") UC_ComputedCols=Array("","","","","","","Price") set UCCart1=VBConstuctCart("UCCart",0,UC_CartColNames,UC_ComputedCols) UCCart1__i=0 %> <% UC_OrderIdSessionVar = "OrderID" If Session(UC_OrderIdSessionVar)="" Then ' Get a unique OrderID number and save to session. UC_tableName = "orderIDs" UC_fieldName = "NextOrderID" UC_sql = "select " & UC_fieldName & " from " & UC_tableName tmp = "ADODB.Recordset" set UC_rsId = Server.CreateObject(tmp) UC_rsId.ActiveConnection = MM_conncart_STRING UC_rsId.Source = UC_sql UC_rsId.CursorType = 0 ' adOpenForwardOnly UC_rsId.CursorLocation = 2 ' adUseServer UC_rsId.LockType = 2 ' adLockPessimistic UC_rsId.Open Session(UC_OrderIdSessionVar) = UC_rsId.Fields(UC_fieldName).value UC_rsId.Fields(UC_fieldName).value = Session(UC_OrderIdSessionVar) + 1 UC_rsId.Update UC_rsId.Close set UC_rsId = Nothing End If %> <% If UCCart1.GetItemCount() <= 0 Then Response.Redirect("cart_empty.asp") %> <% ' *** Edit Operations: declare variables MM_editAction = CStr(Request("URL")) If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Request.QueryString End If ' boolean to abort record edit MM_abortEdit = false ' query string to execute MM_editQuery = "" %> <% ' *** Insert Record: set variables If (CStr(Request("MM_insert")) <> "") Then MM_editConnection = MM_conncart_STRING MM_editTable = "orderuser" MM_editRedirectUrl = "" MM_fieldsStr = "name|value|address|value|tel|value|email|value|card|value|number|value|expires|value|starts|value|issue|value|securitynumber|value|OrderID|value|subtotal|value|vat|value|delivery|value|total|value|confirmed|value|fulfilled|value" MM_columnsStr = "name|',none,''|address|',none,''|tel|',none,''|email|',none,''|card|',none,''|cnumber|',none,''|expires|',none,''|starts|',none,''|issue|',none,''|securitynumber|',none,''|OrderID|',none,''|subtotal|',none,''|vat|',none,''|delivery|',none,''|gtotal|',none,''|confirmed|',none,''|fulfilled|',none,''" ' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, "|") MM_columns = Split(MM_columnsStr, "|") ' set the form values For i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(i+1) = CStr(Request.Form(MM_fields(i))) Next ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If End If %> <% ' *** Insert Record: construct a sql insert statement and execute it If (CStr(Request("MM_insert")) <> "") Then ' create the sql insert statement MM_tableValues = "" MM_dbValues = "" For i = LBound(MM_fields) To UBound(MM_fields) Step 2 FormVal = MM_fields(i+1) MM_typeArray = Split(MM_columns(i+1),",") Delim = MM_typeArray(0) If (Delim = "none") Then Delim = "" AltVal = MM_typeArray(1) If (AltVal = "none") Then AltVal = "" EmptyVal = MM_typeArray(2) If (EmptyVal = "none") Then EmptyVal = "" If (FormVal = "") Then FormVal = EmptyVal Else If (AltVal <> "") Then FormVal = AltVal ElseIf (Delim = "'") Then ' escape quotes FormVal = "'" & Replace(FormVal,"'","''") & "'" Else FormVal = Delim + FormVal + Delim End If End If If (i <> LBound(MM_fields)) Then MM_tableValues = MM_tableValues & "," MM_dbValues = MM_dbValues & "," End if MM_tableValues = MM_tableValues & MM_columns(i) MM_dbValues = MM_dbValues & FormVal Next MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")" If (Not MM_abortEdit) Then ' execute the insert Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End If End If %> <% If InStr(1, MM_editAction, "?", vbTextCompare) = 0 Then MM_editAction = MM_editAction + "?UC_SaveCartToTable=1" Else MM_editAction = MM_editAction + "&UC_SaveCartToTable=1" End If If (CStr(Request("UC_SaveCartToTable")) = "1") Then set UC_connCart = Server.CreateObject("ADODB.Connection") UC_connCart.Open MM_conncart_STRING UC_redirectPage = "cart_thanks.asp" UC_destColName = Array("code","quantity","name","size","colour","price","gtotal") UC_destColType = Array("str","str","str","str","str","str","str") UC_orderId = Session("OrderID") UCCart1.SaveToDatabase UC_connCart,"orderdetails","OrderID","str",UC_orderId,UC_destColName,UC_destColType ' redirect with URL parameters (remove the "UC_SaveCartToTable" query param). if (UC_redirectPage = "") Then UC_redirectPage = CStr(Request.ServerVariables("URL")) If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then newQS = "?" For Each Item In Request.QueryString If (Item <> "UC_SaveCartToTable") Then If (Len(newQS) > 1) Then newQS = newQS & "&" newQS = newQS & Item & "=" & Server.URLencode(Request.QueryString(Item)) End If Next if (Len(newQS) > 1) Then UC_redirectPage = UC_redirectPage & newQS End If Response.Redirect(UC_redirectPage) End If %> <% ' Business rules are coded here. delivery = CSng(0.00) vat = 0.00 grandtotal = CCur(UCCart1.GetColumnTotal("Total")) + delivery %>
::Confirm Order::
 
Please enter your delivery / payment details below.
 
Personal / Delivery  
Order ID: <%=Session("OrderID")%>
Name:
Address:
Telephone:
Email:
 
Payment  
Card Type:
Card Number:
Expiry Date (mm/yy):
Start Date (mm/yy):
Issue Number:
Security Number:
Note: Your security number is the last
3 digits on your signature strip of
your card.
<% For UCCart1__i=0 To UCCart1.GetItemCount()-1 %> <% Next 'UCCart1__i %>
Code Name Size Colour Price Quantity Totals
<%=(UCCart1.GetColumnValue("ProductID",UCCart1__i))%> <%=(UCCart1.GetColumnValue("Name",UCCart1__i))%> <%=(UCCart1.GetColumnValue("Size",UCCart1__i))%> <%=(UCCart1.GetColumnValue("Colour",UCCart1__i))%> <%=(UCCart1.GetColumnValue("Price",UCCart1__i))%> " class="input2"> <%=FormatNumber(UCCart1.GetColumnValue("Total",UCCart1__i), -1, -2, -2, -2)%>
Sub Total: 
<%=FormatNumber(UCCart1.GetColumnTotal("Total"), -1, -2, -2, -2)%>
Delivery: 
<%=FormatNumber((delivery), -1, -2, -2, -2)%>
Grand Total: 
<%=FormatNumber((grandtotal), -1, -2, -2, -2)%>
Complete your Order

Once you are happy with your Delivery / Payment details, please click the Confirm Order button below.

"> ">