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, c_wt 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")
subwt = Cdbl(RS.Fields("c_wt")) * 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
%> |
£<%= FormatNumber(RS.Fields("c_pp")) %> |
|
£<%= FormatNumber(subtot) %> |
<%
thistot = thistot + subtot
totwt = totwt + subwt
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 Deliveryz2 WHERE dname = '" & defaultDeliveryArea & "'"
SET rsDel = adoConn.Execute( sqlString )
'calculate the default countries delivery charge
IF totwt = 0 OR totwt = "" THEN
delcharge = ""
END IF
IF totwt <= rsDel.Fields("wt1") THEN
delcharge = rsDel.Fields("p1")
END IF
IF totwt > rsDel.Fields("wt1") AND totwt <= rsDel.Fields("wt2") THEN
delcharge = rsDel.Fields("p2")
END IF
IF totwt > rsDel.Fields("wt2") AND totwt <= rsDel.Fields("wt3") THEN
delcharge = rsDel.Fields("p3")
END IF
IF totwt > rsDel.Fields("wt3") AND totwt <= rsDel.Fields("wt4") THEN
delcharge = rsDel.Fields("p4")
END IF
IF totwt > rsDel.Fields("wt4") AND totwt <= rsDel.Fields("wt5") THEN
delcharge = rsDel.Fields("p5")
END IF
IF totwt > rsDel.Fields("wt5") AND totwt <= rsDel.Fields("wt6") THEN
delcharge = rsDel.Fields("p6")
END IF
IF totwt > rsDel.Fields("wt6") AND totwt <= rsDel.Fields("wt7") THEN
delcharge = rsDel.Fields("p7")
END IF
IF totwt > rsDel.Fields("wt7") AND totwt <= rsDel.Fields("wt8") THEN
delcharge = rsDel.Fields("p8")
END IF
IF totwt > rsDel.Fields("wt8") AND totwt <= rsDel.Fields("wt9") THEN
delcharge = rsDel.Fields("p9")
END IF
IF totwt > rsDel.Fields("wt9") AND totwt <= rsDel.Fields("wt10") THEN
delcharge = rsDel.Fields("p10")
END IF
IF totwt > rsDel.Fields("wt10") AND totwt <= rsDel.Fields("wt11") THEN
delcharge = rsDel.Fields("p11")
END IF
IF totwt > rsDel.Fields("wt11") AND totwt <= rsDel.Fields("wt12") THEN
delcharge = rsDel.Fields("p12")
END IF
IF totwt > rsDel.Fields("wt12") AND totwt <= rsDel.Fields("wt13") THEN
delcharge = rsDel.Fields("p13")
END IF
IF totwt > rsDel.Fields("wt13") AND totwt <= rsDel.Fields("wt14") THEN
delcharge = rsDel.Fields("p14")
END IF
IF totwt > rsDel.Fields("wt14") AND totwt <= rsDel.Fields("wt15") THEN
delcharge = rsDel.Fields("p15")
END IF
IF totwt > rsDel.Fields("wt15") AND totwt <= rsDel.Fields("wt16") THEN
delcharge = rsDel.Fields("p16")
END IF
IF totwt > rsDel.Fields("wt16") AND totwt <= rsDel.Fields("wt17") THEN
delcharge = rsDel.Fields("p17")
END IF
IF totwt > rsDel.Fields("wt17") THEN
delcharge = rsDel.Fields("p18")
END IF
rsDel.Close
Set rsDel = Nothing
%>
| |
|
|
|
Total Weight |
<%=FormatNumber(totwt)%>kg |
| |
|
|
|
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
'vat calculations
vatsum = (finaltot / 100) * vatrate
finaltot = finaltot + vatsum
%>
|
| |
|
|
|
VAT |
£<%=FormatNumber(vatsum)%> |
| |
|
|
|
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)
adoConn.Close
Set adoConn = Nothing
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, prod_wt 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")
pwt = RS2.Fields("prod_wt")
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 & "', '" & pwt & "')"
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
adoConn.Close
Set adoConn = Nothing
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)
adoConn.Close
Set adoConn = Nothing
Response.Status = "302 Object moved"
Response.Redirect "cart.asp?action=view&myLink=" & myLink
%>
<% Case Else ' menu
adoConn.Close
Set adoConn = Nothing
Response.Status = "302 Object moved"
Response.Redirect "cart.asp?action=view&myLink=" & myLink
%>
<%
End Select
%> |