Your
shopping basket
<%
Dim finaltot, vatcost, CountA, Sdatum3, thissesh, count, thistot, thisweight, delcharge, thiscalc, totalweight, firstcharge, surcharge, surcharg2
%> <%
Sub grabcustomer
IF Request.Cookies("BR") = "" THEN
thissesh = "BR" + Session.SessionID
extraunique = NOW
myMnte = Minute(extraunique)
IF Len(myMnte) <2 THEN
myMnte = "0" & myMnte
END IF
mySecs = Second(extraunique)
IF Len(mySecs) <2 THEN
mySecs = "0" & mySecs
END IF
myDay = Day(extraunique)
IF Len(myDay) <2 THEN
myDay = "0" & myDay
END IF
extraunique = myDay & mySecs & myMnte
thissesh = thissesh & extraunique
Response.Cookies("BR")= thissesh
Response.Cookies("BR").Expires = Date + 30
Response.Cookies("BR").Path = "/"
Response.Cookies("BR").Secure = FALSE
ELSE
thissesh = Request.Cookies("BR")
END IF
End Sub
%> <% Sub bottombuttons %>
|
| |
|
|
|
You must have
session cookies enabled on your computer. Why? |
| |
|
|
<% End sub %> <%
Dim sAction
sAction = CStr(Request("action"))
Select Case sAction
%> <% Case "view"
grabcustomer
' Get the shopping cart
sqlString = "SELECT c_id, c_prodID, prod_pn, c_pp, prod_ID, c_pq, c_colour, prod_name FROM Cart, Productz WHERE c_userID = '" & thissesh & "' AND c_prodID = prod_ID ORDER BY prod_name ASC"
SET RS = adoConn.Execute( sqlString )
%>
| |
|
|
|
|
|
| Part Number: |
Product: |
Option: |
Price Each: |
Quantity: |
Subtotal: |
<%
count = 0
thistot = 0
RS.MoveFirst
Do While Not RS.EOF
subtot = Cdbl(RS.Fields("c_pp")) * RS.Fields("c_pq")
%>
| <%= RS.Fields("prod_pn") %> |
<%= RS.Fields("prod_name") %> |
<% IF RS.Fields("c_colour") = "" THEN
Response.Write "n/a"
ELSE
Response.Write RS.Fields("c_colour")
END IF
%> |
£<%= RS.Fields("c_pp") %> |
|
£<%= FormatNumber(subtot) %> |
<%
thistot = thistot + subtot
subtot = 0
count = count + 1
RS.MoveNext
Loop
%>
| |
|
|
|
Goods Total: |
<% Response.Write "£" & FormatNumber(thistot) & ""%>
|
<%
'Get UK delivery charge, and free order capping
sqlString = "SELECT * FROM Deliveryz WHERE d_area = '" & defaultDeliveryArea & "'"
SET rsDel = adoConn.Execute( sqlString )
'calculate the default countries delivery charge
delfigz = thistot
IF delfigz <= Cdbl(pbandA) THEN
delcharge = rsDel.Fields("d_price1")
END IF
IF delfigz > Cdbl(pbandA) AND delfigz <= Cdbl(pbandB) THEN
delcharge = rsDel.Fields("d_price2")
END IF
IF delfigz > Cdbl(pbandB) THEN
delcharge = rsDel.Fields("d_price3")
END IF
delfigz = Cdbl(delfigz)
rsDel.Close
Set rsDel = Nothing
%>
| |
|
|
|
UK Delivery** |
<%
IF thistot = "" OR thistot = 0 THEN
delcharge = 0
finaltot = thistot
Response.Write "N/A"
ELSE
IF delcharge = "" OR delcharge = 0 THEN
Response.Write "FREE"
finaltot = thistot
ELSE
Response.Write "£" & FormatNumber(delcharge) & ""
finaltot = thistot + delcharge
END IF
END IF
%>
|
| |
|
|
|
Order Total: |
<% Response.Write "£" & FormatNumber(finaltot) & ""%>
|
<%
IF count <1 THEN
response.write ""
response.write "Your basket is currently empty! | "
END IF
RS.Close
Set RS = Nothing
%> <% bottombuttons %>
<% Case "update"
grabcustomer
pid = Request("pid")
pq = Request("pq")
pcol = Request("pcol")
myLink = Request("myLink")
IF Request("pq") = "" THEN
pq = 0
Else
pq = Request("pq")
END IF
IF pq = 0 THEN
IF pcol <> "" THEN
mySQL = "DELETE FROM Cart WHERE c_prodID = '" & pid & "' AND c_userID = '" & thissesh & "' AND c_colour = '" & pcol & "'"
ELSE
mySQL = "DELETE FROM Cart WHERE c_prodID = '" & pid & "' AND c_userID = '" & thissesh & "'"
END IF
ELSE
mySQL = "UPDATE Cart SET c_pq = '" & pq & "' WHERE c_prodID = '" & pid & "' AND c_userID = '" & thissesh & "'"
END IF
adoConn.Execute(mySQL)
Response.Status = "302 Object moved"
Response.Redirect "cart.asp?action=view&myLink=" & myLink
%> <% Case "add"
grabcustomer
Dim pq, pp
pid = Request("pid")
pq = Request("pq")
pcol = Request("pcol")
pcol = LCASE(pcol)
IF Request("pq") ="" OR Request("pq") ="0" THEN
Response.Write "You'll need to enter the quantity you require. You can remove an item from your shopping basket by entering 0 on the View Basket page. "
ELSE
sqlString = "SELECT prod_ID, prod_price, prod_pn, prod_name FROM Productz WHERE prod_ID = '" & pid & "'"
SET RS2 = adoConn.Execute( sqlString )
pp = RS2.Fields("prod_price")
ppn = RS2.Fields("prod_pn")
pname = RS2.Fields("prod_name")
IF pid <> "" AND pq <> "" THEN
sqlString = "SELECT * FROM Cart WHERE c_userID= '" & thissesh & "' AND c_prodID ='" & pid & "' AND c_colour = '" & pcol & "'"
SET RS = adoConn.Execute( sqlString )
IF RS.EOF THEN
sqlString = "INSERT INTO Cart VALUES ('','" & pid & "','" & pp & "','" & pq & "','" & thissesh & "','" & ppn & "','" & pname & "', '" & pcol & "')"
ELSE
' pq = pq + RS.Fields("c_pq")
thisOne = RS.Fields("c_id")
sqlString = "UPDATE Cart SET c_pq = c_pq + '" & pq & "' WHERE c_id = '" & thisOne & "'"
END IF
END IF
RS.Close
RS2.Close
SET RS = Nothing
SET RS2 = Nothing
adoConn.Execute sqlString
Response.Status = "302 Object moved"
Response.Redirect "cart.asp?action=view&myLink=" & myLink
END IF
%> <% Case "empty"
grabcustomer
myLink = Request("myLink")
mySQL = "DELETE FROM Cart WHERE c_userID = '" & thissesh & "'"
adoConn.Execute(mySQL)
Response.Status = "302 Object moved"
Response.Redirect "cart.asp?action=view&myLink=" & myLink
%> <% Case Else ' menu
Response.Status = "302 Object moved"
Response.Redirect "cart.asp?action=view&myLink=" & myLink
%> <%
End Select
%> |