häll i er nu...
kalssen "Order"
Option Explicit
Public resell As String
Public moms As String
Public User_ID As Integer
Public webshop As String
Public SPass As String
Public ResellerPath As String
Dim sComment As String
Dim sCompany As String
Dim sName As String
Dim sAddress1 As String
Dim sAddress2 As String
Dim sZip As String
Dim sCity As String
Dim sCountry As String
Dim sState As String
Dim sIP As String
Public objConn As Object
'Connectionstring to the db
'----------------------------------------------------------------------------------
Private Property Get ConnectionString()
ConnectionString = "Driver={Mysql};Server=10.0.0.1;Database=aShop;UID=test;PWD=test"
End Property
'Destry the object
'----------------------------------------------------------------------------------
Public Sub DestroyObject(ByRef obConn As ADODB.Connection)
If IsObject(obConn) Then
obConn.Close
Set obConn = Nothing
End If
End Sub
'Open the DB
'----------------------------------------------------------------------------------
Public Function GetConn() As ADODB.Connection
Dim ojConn As ADODB.Connection
Set ojConn = CreateObject("ADODB.Connection")
ojConn.Open ConnectionString
Set GetConn = ojConn
End Function
'Reseller Querystring?
'----------------------------------------------------------------------------------
Public Sub Reseller(Optional id)
Dim Property As New Property
If id <> "" Then
resell = Property.ResellerQueryStr(CInt(id))
Else
resell = "?res="
End If
End Sub
'Reseller Path
'----------------------------------------------------------------------------------
Public Sub ResellPath(Optional id As Integer)
If id > 0 Then
ResellerPath = id & "\"
Else
ResellerPath = ""
End If
End Sub
'Show/hide Vat
Public Sub Vat(momsen As String)
moms = momsen
End Sub
'Is the user logged in?
Public Sub User_Logged(id As Integer)
User_ID = id
End Sub
'get shop username
Public Sub ShopID(shoppen As String)
webshop = shoppen
End Sub
'get shop password
Public Sub ShopPass(shoppen As String)
SPass = shoppen
End Sub
Public Property Let Save_Comment(data As String)
sComment = data
End Property
Public Property Let Save_Company(data As String)
sCompany = data
End Property
Public Property Let Save_Name(data As String)
sName = data
End Property
Public Property Let Save_Address1(data As String)
sAddress1 = data
End Property
Public Property Let Save_Address2(data As String)
sAddress2 = data
End Property
Public Property Let Save_Zip(data As String)
sZip = data
End Property
Public Property Let Save_City(data As String)
sCity = data
End Property
Public Property Let Save_Country(data As String)
sCountry = data
End Property
Public Property Let Save_State(data As String)
sState = data
End Property
Public Property Let Save_IP(data As String)
sIP = data
End Property
'Get Cart Items
'----------------------------------------------------------------------------------
Public Function SaveCart(cart_user As String)
'Dim Misc As New Misc
Dim disc As Recordset
Dim RS As Recordset
Dim mSQL As String
Dim SQL As String
Dim sdSQL As String
Dim strMisc
Dim i As Integer
Dim Property As New Property
Dim TheShop
Dim ordern As Integer
Dim oSQL As String
'get shop id
TheShop = Property.GetWebshop(webshop, SPass)
'get cart items
Set objConn = GetConn()
mSQL = "Select Cart_Prod_ID, Cart_User_ID, Cart_Items, Cart_ID From Cart Where Cart_Webshop=" & CInt(TheShop(0, 0)) & " And Cart_User_ID='" & cart_user & "'"
Set disc = objConn.Execute(mSQL)
'check if there's anything in the db
If Not disc.EOF Then
strMisc = disc.GetRows()
Else
strMisc = Null
End If
disc.Close
Set disc = Nothing
Call DestroyObject(objConn)
'check if there is any products in the cart
If Not IsNull(strMisc) Then
Set objConn = GetConn()
oSQL = "Insert Into Orders"
oSQL = oSQL & "(Order_User, Order_Webshop, Order_Date, Order_IP, Order_Comment, Order_Company, Order_Name, Order_Address1, Order_Address2, Order_Zip, Order_City, Order_Country, Order_State)"
oSQL = oSQL & "VALUES(" & User_ID & ", " & CInt(TheShop(0, 0)) & ", '" & Now() & "', '" & sIP & "', '" & sComment & "', '" & sCompany & "', '" & sName & "', '" & sAddress1 & "', '" & sAddress2 & "', '" & sZip & "', '" & sCity & "', '" & sCountry & "', '" & sState & "')"
objConn.Execute (oSQL), , 128
Set RS = objConn.Execute("select last_insert_id()")
ordern = RS(0)
RS.Close
Set RS = Nothing
Call DestroyObject(objConn)
'loop and replace
For i = 0 To UBound(strMisc, 2)
Set objConn = GetConn()
'save the order items
SQL = "Insert Into OrderItems"
SQL = SQL & "(OI_Prod, OI_Order, OI_Items)"
SQL = SQL & "VALUES(" & strMisc(0, i) & ", " & ordern & ", " & strMisc(2, i) & ")"
objConn.Execute (SQL), , 128
Call DestroyObject(objConn)
Next
Set objConn = GetConn()
sdSQL = "Delete From Cart Where Cart_Webshop=" & CInt(TheShop(0, 0)) & " And Cart_User_ID='" & cart_user & "'"
objConn.Execute (sdSQL), , 128
objConn.Execute ("Optimize Table Cart")
Call DestroyObject(objConn)
'send it back
SaveCart = True
Else
'send it back
SaveCart = False
End If
'send it back
End Function
'lets print the page
Public Function page()
Dim Property As New Property
Dim TheShop
Dim Category As New Category
Dim ThePage As String
'make sure the shop is allowed to be used and get some info
TheShop = Property.GetWebshop(webshop, SPass)
'Does the Webshop exists?
If Not IsNull(TheShop) Then
'Is The Webshop Active????
If TheShop(4, 0) = 0 Then
'Let's get the template
ThePage = Property.GetTemplate("pay.htm", CStr(TheShop(2, 0)), ResellerPath)
'Common replaces
ThePage = Property.CommonReplaces(CInt(TheShop(0, 0)), ThePage, "" & CStr(TheShop(1, 0)), moms, "pay.asp", resell)
Else
'The Webshop is closed by Admin
ThePage = "<font face=""Verdana"" size=""2""><b>Error!</b><br>This webshop is not active, please contact the server administrator.</font>"
End If
Else
'shop not found
ThePage = "<font face=""Verdana"" size=""2""><b>Error!</b><br>Please check the ShopID and Password. If the error remains, please contact the server administrator.</font>"
End If
page = ThePage
End Function
asp filen "pay.asp":
<!--#include file="config.asp" -->
<%
Dim resell
Dim sorder
If Session("User_ID") = "" Or Session("User_ID") = False Then
Response.Redirect "login.asp?"& Request.ServerVariables("QUERY_STRING")
End If
Set pay = Server.CreateObject("aShop.Order")
'check reseller
If Request.Querystring("res") <> "" Then
resell = Cint(Request.Querystring("res"))
Call pay.ResellPath(Cint(Request.Querystring("res")))
End If
Call pay.Reseller(resell)
'check vat
If Request.Cookies("aSHOP")("vat")="show" Then
Call pay.Vat("show")
Else
Call pay.Vat("hide")
End If
'Check if user is logged in
pay.User_Logged(CInt(Session("User_ID")))
'Check shop, category and product, then show the page!
Call pay.ShopID(Cstr(ShopID))
Call pay.ShopPass(Cstr(Password))
If Request.Form("comments")<> "" Then pay.Save_Comment = Replace(Request.Form("comments"), "'", "''")
If Request.Form("company")<> "" Then pay.Save_Company = Replace(Request.Form("company"), "'", "''")
If Request.Form("name")<> "" Then pay.Save_Name = Replace(Request.Form("name"), "'", "''")
If Request.Form("address1")<> "" Then pay.Save_Address1 = Replace(Request.Form("address1"), "'", "''")
If Request.Form("address2")<> "" Then pay.Save_Address2 = Replace(Request.Form("address2"), "'", "''")
If Request.Form("zip")<> "" Then pay.Save_Zip = Replace(Request.Form("zip"), "'", "''")
If Request.Form("city")<> "" Then pay.Save_City = Replace(Request.Form("city"), "'", "''")
If Request.Form("country")<> "" Then pay.Save_Country = Replace(Request.Form("country"), "'", "''")
If Request.Form("state")<> "" Then pay.Save_State = Replace(Request.Form("state"), "'", "''")
pay.Save_IP = Request.ServerVariables("REMOTE_HOST")
sorder = pay.SaveCart(Request.Cookies("Shop")("User1"))
If sorder= True Then
Response.Write pay.Page()
Else
Response.Redirect "checkout.asp"
End If
Set pay = Nothing
%>