|
 |
<%
Dim sAction
sAction = CStr(Request("action"))
Select Case sAction
' check they have a basket first
' check
%> <% Case "preview"
dArea = Request("dArea")
thissesh = Request.Cookies("BR")
IF thissesh = "" THEN
adoConn.Close
Set adoConn = Nothing
Response.Status = "302 Object moved"
Response.Redirect "error.asp?error=1"
END IF
SET rsDel = adoConn.Execute("SELECT * FROM Deliveryz WHERE d_id = '" & dArea & "'")
addme = Request("addme")
Sdatum3 = Request("Sdatum3")
ifirstnames = Trim(Request("ifirstnames"))
ifirstnames = Replace(ifirstnames,"'","")
ifirstnames = Replace(ifirstnames,"&","and")
isurname = Trim(Request("isurname"))
isurname = Replace(isurname,"'","")
isurname = Replace(isurname,"&","and")
icompany = Trim(Request("icompany"))
icompany = Replace(icompany,"'","")
icompany = Replace(icompany,"&","and")
iadd1 = Trim(Request("iadd1"))
iadd1 = Replace(iadd1,"'","")
iadd1 = Replace(iadd1,"&","and")
iadd2 = Trim(Request("iadd2"))
iadd2 = Replace(iadd2,"'","")
iadd2 = Replace(iadd2,"&","and")
itown = Trim(Request("itown"))
itown = Replace(itown,"'","")
itown = Replace(itown,"&","and")
ipostcode = UCASE(Trim(Request("ipostcode")))
ipostcode = Replace(ipostcode,"'","")
ipostcode = Replace(ipostcode,"&","and")
icounty = Trim(Request("istate"))
icounty = Replace(icounty,"'","")
icounty = Replace(icounty,"&","and")
icountry = Request("icountry")
email = LCase(Trim(Request("email")))
email = Replace(email,"'","")
email = Replace(email,"&","")
tel = Trim(Request("tel"))
tel = Replace(tel,"'","")
tel = Replace(tel,"&","and")
paymethod = Request("paymethod")
buymsg = Trim(Request("buymsg"))
buymsg = Replace(buymsg,"'","''")
buymsg = Replace(buymsg,vbcrlf," ")
tree_date = Trim(Request("tree_date"))
tree_date = Replace(tree_date,"'","")
sameasinv = Cint(Request("sameasinv"))
IF sameasinv = 1 THEN
dfirstnames = ifirstnames
dsurname = isurname
ELSE
dfirstnames = Trim(Request("dfirstnames"))
dfirstnames = Replace(dfirstnames,"'","")
dfirstnames = Replace(dfirstnames,"&","and")
dsurname = Trim(Request("dsurname"))
dsurname = Replace(dsurname,"'","")
dsurname = Replace(dsurname,"&","and")
END IF
IF sameasinv = 1 THEN
dcompany = icompany
ELSE
dcompany = Trim(Request("dcompany"))
dcompany = Replace(dcompany,"'","")
dcompany = Replace(dcompany,"&","and")
END IF
IF sameasinv = 1 THEN
dadd1 = iadd1
ELSE
dadd1 = Trim(Request("dadd1"))
dadd1 = Replace(dadd1,"'","")
dadd1 = Replace(dadd1,"&","and")
END IF
IF sameasinv = 1 THEN
dadd2 = iadd2
ELSE
dadd2 = Trim(Request("dadd2"))
dadd2 = Replace(dadd2,"'","")
dadd2 = Replace(dadd2,"&","and")
END IF
IF sameasinv = 1 THEN
dtown = itown
ELSE
dtown = Trim(Request("dtown"))
dtown = Replace(dtown,"'","")
dtown = Replace(dtown,"&","and")
END IF
IF sameasinv = 1 THEN
dcounty = icounty
ELSE
dcounty = Trim(Request("dstate"))
dcounty = Replace(dcounty,"'","")
dcounty = Replace(dcounty,"&","and")
END IF
IF sameasinv = 1 THEN
dpostcode = ipostcode
ELSE
dpostcode = UCASE(Trim(Request("dpostcode")))
dpostcode = Replace(dpostcode,"'","")
dpostcode = Replace(dpostcode,"&","")
END IF
IF sameasinv = 1 THEN
dtel = tel
ELSE
dtel = UCASE(Trim(Request("dtel")))
dtel = Replace(dtel,"'","")
dtel = Replace(dtel,"&","")
END IF
IF sameasinv = 1 THEN
dcountry = icountry
dNation = iNation
ELSE
dcountry = Trim(Request("dcountry"))
END IF
vouchercode = UCASE(Trim(Request("vouchercode")))
IF dfirstnames = "" OR dsurname = "" OR dadd1 = "" OR dpostcode = "" OR email = "" THEN
errmsg = errmsg & "You must complete your delivery details in order for your order to be processed!"
errmsg = errmsg & " Required fields include; delivery name, delivery address and email."
END IF
' get goods value
SET RS = adoConn.Execute("SELECT c_id, c_prodID, prod_pn, c_pp, prod_id, c_pq, c_colour, prod_name, prod_pgn, prod_typ, prod_main, prod_delinc FROM Cart, Productz WHERE c_userID = '" & thissesh & "' AND c_prodID = prod_id AND c_proc = '0' ORDER BY prod_name ASC")
thistot = 0
RS.MoveFirst
Do While Not RS.EOF
subtot = Cdbl(RS.Fields("c_pp")) * RS.Fields("c_pq")
thistot = thistot + subtot
subtot = 0
RS.MoveNext
Loop
goodstotal = thistot
RS.Close
Set RS = Nothing
' deal with vouchers updates
IF vouchercode <> "" THEN
Set rsFind = adoConn.Execute("SELECT * FROM Voucherz WHERE v_code = '" & vouchercode & "'")
IF rsFind.EOF OR rsFind.RecordCount = 0 THEN
errmsg = errmsg & " We cannot locate this Voucher Code, please return and ensure it is spelt correctly. "
vouchercode = ""
ELSE
IF Cint(rsFind.Fields("v_live")) = 1 THEN
errmsg = errmsg & "This Voucher Code has expired. "
vouchercode = ""
ELSE
IF Cdbl(goodstotal) < Cdbl(rsFind.Fields("v_band1")) THEN
discount1 = 0
END IF
IF Cdbl(goodstotal) > Cdbl(rsFind.Fields("v_band1")) THEN
discount1 = Cdbl(rsFind.Fields("v_price1"))
END IF
IF Cdbl(goodstotal) > Cdbl(rsFind.Fields("v_band2")) THEN
discount1 = Cdbl(rsFind.Fields("v_price2"))
END IF
IF Cdbl(goodstotal) > Cdbl(rsFind.Fields("v_band3")) THEN
discount1 = Cdbl(rsFind.Fields("v_price3"))
END IF
IF Cint(rsFind.Fields("v_fixpercent")) = 1 THEN
discount = discount1
ELSE
discount = (Cdbl(goodstotal) * discount1) / 100
discount = Round(discount,2)
END IF
END IF
END IF
rsFind.Close
Set rsFind = Nothing
ELSE
discount = 0
END IF
IF errmsg <> "" THEN
%>
<%
ELSE
%> Please confirm your order
This is your order, please confirm all details are correct.
| Invoice Address |
Delivery Address |
<%=ifirstnames%> <%=isurname%>
<%
IF icompany <> "" THEN
Response.Write vbcrlf & " " & icompany & " "
END IF
IF iadd1 <> "" THEN
Response.Write vbcrlf & " " & iadd1 & " "
END IF
IF iadd2 <> "" THEN
Response.Write vbcrlf & " " & iadd2 & " "
END IF
IF itown <> "" THEN
Response.Write vbcrlf & " " & itown & " "
END IF
IF icounty <> "" THEN
Response.Write vbcrlf & " " & icounty & " "
END IF
IF ipostcode <> "" THEN
Response.Write vbcrlf & " " & ipostcode & " "
END IF
IF iNation <> "" THEN
Response.Write vbcrlf & " " & iNation
END IF
Response.Write " "
%>
Email: <%=email%>
Tel: <%=tel%> |
<%=dfirstnames%> <%=dsurname%>
<%
IF dcompany <> "" THEN
Response.Write vbcrlf & " " & dcompany & " "
END IF
IF dadd1 <> "" THEN
Response.Write vbcrlf & " " & dadd1 & " "
END IF
IF dadd2 <> "" THEN
Response.Write vbcrlf & " " & dadd2 & " "
END IF
IF dtown <> "" THEN
Response.Write vbcrlf & " " & dtown & " "
END IF
IF dcounty <> "" THEN
Response.Write vbcrlf & " " & dcounty & " "
END IF
IF dpostcode <> "" THEN
Response.Write vbcrlf & " " & dpostcode & " "
END IF
IF dNation <> "" THEN
Response.Write vbcrlf & " " & dNation
END IF
Response.Write " "
%>
Tel: <%=dtel%>
|
| |
|
<%
IF paymethod = "sagepay" THEN
paymethodmessage = "Securely online with SagePay"
END IF
IF paymethod = "cheque" THEN
paymethodmessage = "Cheque in Post"
END IF
IF paymethod = "phone" THEN
paymethodmessage = "By Phone"
END IF
%>
| Payment Method: |
<%=paymethodmessage%> |
| |
|
<% IF tree_date <> "" THEN %>
| Tree Delivery; week beginning: |
<%=tree_date%> |
| |
|
<%
END IF
IF buymsg <> "" THEN
delmsg2 = Replace(buymsg,"''","'")
%>
| Special Instructions |
|
| <%=delmsg2%> |
| |
|
<% END IF %>
<%
' Get the cart details
SET RS = adoConn.Execute("SELECT c_id, c_prodID, prod_pn, c_pp, prod_id, c_pq, c_colour, c_wt, prod_name, prod_pgn, prod_typ, prod_main, prod_delinc FROM Cart, Productz WHERE c_userID = '" & thissesh & "' AND c_prodID = prod_id AND c_proc = '0' ORDER BY prod_name ASC")
%>
| Product: |
Price Each: |
Quantity: |
Subtotal: |
<%
count = 0
heavyitem = 0
thistot = 0
extracharge = 0
RS.MoveFirst
Do While Not RS.EOF
subtot = Cdbl(RS.Fields("c_pp")) * RS.Fields("c_pq")
IF Cint(RS.Fields("prod_delinc")) = 1 THEN
heavyitem = heavyitem + Cint(RS.Fields("c_pq"))
ELSE
cartweight = cartweight + (Cint(RS.Fields("c_wt")) * Cint(RS.Fields("c_pq")))
END IF
%>
| <%=Left(Replace(RS.Fields("prod_name"),"''","'"),60)%> |
£<%=RS.Fields("c_pp")%> |
<%=RS.Fields("c_pq")%> |
£<%= FormatNumber(subtot) %> |
<%
thistot = thistot + subtot
subtot = 0
count = count + 1
RS.MoveNext
Loop
%>
| |
Goods Total: |
<% Response.Write "£" & FormatNumber(goodstotal) & ""%>
|
<%
'Get default delivery charge
SET rsDel = adoConn.Execute("SELECT * FROM Deliveryz WHERE d_id = '" & dArea & "'")
isvat = Cint(rsDel.Fields("d_isvat"))
delname = rsDel.Fields("d_name")
'calculate the default countries delivery charge
IF cartweight <= 100 THEN
delcharge = rsDel.Fields("d_p1")
END IF
IF cartweight > 100 AND cartweight <= 250 THEN
delcharge = rsDel.Fields("d_p2")
END IF
IF cartweight > 250 AND cartweight <= 500 THEN
delcharge = rsDel.Fields("d_p3")
END IF
IF cartweight > 500 AND cartweight <= 750 THEN
delcharge = rsDel.Fields("d_p4")
END IF
IF cartweight > 750 AND cartweight <= 1000 THEN
delcharge = rsDel.Fields("d_p5")
END IF
IF cartweight > 1000 AND cartweight <= 1250 THEN
delcharge = rsDel.Fields("d_p6")
END IF
IF cartweight > 1250 AND cartweight <= 1500 THEN
delcharge = rsDel.Fields("d_p7")
END IF
IF cartweight > 1500 THEN
delcharge = rsDel.Fields("d_p8")
END IF
IF cartweight = 0 THEN
delcharge = 0
END IF
IF heavyitem > 0 THEN
extracharge = heavyitem * Cdbl(rsDel.Fields("d_ptrees"))
END IF
delcharge = delcharge + extracharge
rsDel.Close
Set rsDel = Nothing
IF discount <> 0 THEN
%>
| |
Discount: |
-£<%=FormatNumber(discount)%> |
<% END IF %>
| <%=delname%> |
Delivery |
<%
IF thistot = 0 THEN
delcharge = 0
Response.Write "N/A"
ELSE
IF delcharge = "" OR delcharge = 0 OR delcharge = "0.00" THEN
Response.Write "FREE"
ELSE
Response.Write "£" & FormatNumber(delcharge) & ""
END IF
END IF
finaltot = thistot
finaltot = finaltot + delcharge
finaltot = finaltot - discount
IF isvat = 1 THEN
'vat calculations
vatsum = (finaltot / 100) * 15
vatsum = Round(vatsum,2)
ELSE
vatsum = 0
END IF
finaltot = finaltot + vatsum
%>
|
<% IF vatsum <> 0 THEN %>
| |
VAT:* |
£<%=FormatNumber(vatsum)%> |
<% END IF %>
| |
Order Total: |
<% Response.Write "£" & FormatNumber(finaltot) & ""%>
|
<%
RS.Close
Set RS = Nothing
%>
| |
|
|
|
| |
|
| Please ensure that your
details are correct before clicking to the next stage.
You will be unable to click back to amend your details
once you have left this page.
|
<%
END IF ' end they have entered details
%>
<%
Case Else
thissesh = Request.Cookies("BR")
' check the cookie is present
IF thissesh = "" THEN
adoConn.Close
Set adoConn = Nothing
Response.Status = "302 Object moved"
Response.Redirect "error.asp?error=1"
END IF
' check they have items in their basket
Set rsFind = adoConn.Execute("SELECT c_id, c_iamatree FROM Cart WHERE c_userID = '" & thissesh & "' AND c_proc = '0' ORDER BY c_id ASC")
IF rsFind.EOF OR rsFind.RecordCount = 0 THEN
%>
ERROR
Your basket appears to empty.
You may have just completed an order, in which case your
basket will have been closed as the order itself is created.
Else, if you are sure there should be items in your shopping
basket then it may be that your security or cookie settings
are preventing our site from matching you to your basket.
You can find more information on our cookies and why we need
them here. |
<%
ELSE
treecount = 0
Do While NOT rsFind.EOF
treecount = treecount + Cint(rsFind.Fields("c_iamatree"))
rsFind.MoveNext
Loop
Sdatum3 = NOW()
%> We are pleased to accept credit and debit
card payments securely online with SagePay. Once we have received
your delivery details and you confirm your order you will be passed
to SagePay's secure server where you can complete payment. You
can choose your preferred method of payment below.
Your order will be sent to the following address. Please enter
your invoice address and delivery information and click Continue
to continue.
For Christmas Tree Orders, please provide a mobile or land line
number so that the delivery driver can ring 15 min's before delivery
(this should avoid any re-delivery charges).
Please state if your christmas tree can be left with a neighbour
or left somewhere secure.
<%
END IF
rsFind.Close
Set rsFind = Nothing
%> <%
End Select
%>
|