Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding a search to shopping cart

Status
Not open for further replies.

zickler

Technical User
Mar 6, 2004
28
IE
Hi
I want to add a simple search facility to a shopping cart ( a.shopkart 2.0) and also a price filter, could anyone help please. This is the page that the search and fiter would go to display the products. Thanks

<!-- #include file="db.asp" -->
<%
Response.Buffer = true
Dim catid, strcat
catid = Request.QueryString("id")
strcat = Request.QueryString ("cat")

If catid = "" OR (IsNumeric(catid) = false) Then
Response.Redirect "default.asp"
End if

Dim catname, productslist
sub productInfo(connObj,category)
q = chr(34)
set cmd = server.CreateObject("ADODB.Command")
cmd.ActiveConnection = connObj
cmd.CommandText = "qryProdsCategory"
cmd.CommandType = adCmdStoredProc
set param = cmd.CreateParameter("theCategory",adInteger,adParamInput,4)
cmd.Parameters.Append(param)
cmd("theCategory") = Cint(category)
set rs = server.CreateObject("ADODB.Recordset")
set rs = cmd.Execute

if not rs.EOF then
catname = rs("catdescription")
strHTML = "<table border=0 cellPadding=4 cellSpacing=2 width='100%'>"
strHTML = strHTML & "<tr>"

i = 1
while not rs.EOF
strHTML = strHTML & "<td valign=top>" & vbcrlf
strHTML = strHTML & "<img src=" & q& "images/" & rs("cimageurl") &q& " align=" & q& "left"& q & ">" & vbcrlf

'strHTML = strHTML & "<img src=" & q& "images/small/" & rs("cimageurl") &q& " align=" & q& "left"& q & ">" & vbcrlf
strHTML = strHTML & "<h4>" & rs("cname") & "</h4>" & vbcrlf
'strHTML = strHTML & "<p><font size=-1><a href="&q&"product.asp?id=" & rs("catalogID") &q&">More</a></font></p>" & vbcrlf
strHTML = strHTML & "<p><font size=-1><a href="&q&"product.asp?id=" & rs("catalogID") &q&"><img src='.\images\more.jpg" & " '></a></font></p>" & vbcrlf
strHTML = strHTML & "<p>Price: " & FormatCurrency(rs("cprice"),2) & "<br>" & vbcrlf
strHTML = strHTML & "<form action="&q&"addprod.asp"&q&" method="&q&"POST"&q&" name=form"&i&" onSubmit="&q& "return checkItems(form"&i&")" & q&">" & vbcrlf
strHTML = strHTML & "<input type="&q&"hidden"&q&" name="&q&"fproductid"&q&" value="&q & rs("catalogID")& q&">" & vbcrlf
strHTML = strHTML & "Quantity: <input maxLength="&q&"1"&q&" name="&q&"fquantity"&q&" size=2 value="&q&"1"&q&">" & vbcrlf
strHTML = strHTML & "<input type="&q&"submit"&q&" value="&q&"ORDER"&q&" name="&q&"order"&q&" style="&q&"font-family: Arial; color: #800000; font-weight: bold"&q&">"
strHTML = strHTML & "</form></td>" & vbcrlf
if (i mod 2) = 0 then
strHTML = strHTML & "</tr><tr>" & vbcrlf
end if
i = i + 1
rs.MoveNext
wend

strHTML = strHTML & "<tr></table>"
else
strHTML = "Product information not found."
catname = "Error"
end if
productslist = strHTML
rs.Close
set rs = nothing
set cmd = nothing

end sub

%>
<html>
<head>
<title>Products</title>
<SCRIPT LANGUAGE=javascript>
<!--
function checkItems(formobj)
{
var quant = formobj.fquantity.value
if (isNaN(quant) == true || quant < 1 || quant > 9)
{
alert("Please enter a number between 1 and 9");
formobj.fquantity.focus();
return false
}else
{
return true;
}
}
//-->
</SCRIPT>
<link rel="stylesheet" type="text/css" href="eposter.css">
</head>
<body bgcolor="#000000" text="#FF8000" link="#00FF00" vlink="#00FF00" alink="#00FF00">

<table border="0" width="600" cellpadding="4">
<tr>
<td width="100%" colspan="2" valign="top">
<h3><img src="images/fit net 2.jpg" alt="Fit net " width="150" height="100">
<br><font face="Arial">
<%
'on error resume next
call openConn()
if dbc.errors.count > 0 then
Response.Write "Error accessing database."
else
call productInfo(dbc,catid)
end if
call closeConn()
response.write catname
%>
</font></h3></td>
</tr>
<tr>
<td width="120"></td>
<td width="480">
<%= productslist %>
</td>
</tr>
</table>


</body>
</html>
 
What is the code you posted doing? or is that the cart scripts? Where and how is the data for teh tiems being retained? in a DB or by static data in the pages being passed here and there?

I'm basically asking for details on your in place ssytem. Not many of us will be able to tear your code apart and tell you exactly the perfect answer and such. Try doing all that prior to posting or even possibly starting something off on your own and then coming on over with some questions on walls you need to get over

shopping carts usually don't have much functionality in searching other then what has been retained in them also.

so the code above (unless it is a start to something you are working on) will not help all that much.

I would suggest starting from scratch and then incorporating the search functions into the cart.
If it is a database driven cart then a easy SELECT on the passed criteria will do. If it is something other then that, then try searching for examples on searching or querying the resource at hand via ASP



___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
Thanks for responding so quickly, apologies for not providing enough information. The script above is one of the cart scripts alright it is called products.asp and it displays the product name price and small photo image. The data is being stored in a Microsoft Access DB.

Thanks for responding.
 
sense the data is stored in MS then the most comlication that will be part of a search option will be getting the SQL syntax and passing the values to search by down

using LIKE clasues in JetSQL will be something to use on a textbox search where the user can enter their own values. or using a clickable link to pass a form object along will be another method.

a basic JetSQL SELECT with both methods would be something to the effect of
LIKE example
Dim SQLStatement
SQLStatement = "SELECT * FROM tblName WHERE someID LIKE '*" & Request.Form("parameterPassed") & "*'"

and or then passing a valid ID to the DB
Dim SQLStatement
SQLStatement = "SELECT * FROM tblName WHERE someID = '" & Request.Form("parameterPassed") & "'"

DevGuru has a geared to JetSQL reference giude that should help
DevGuru JetSQL Reference

other then that, it's simply passing the values to the server and formatting the returns form the SQL hits

how far are you in the understanding of those steps thus far

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
Yes I can kind of follow what you are saying, will give it a go and mail back if I hit those walls !

Thanks
 
[thumbsup2]

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
when I said
onpnt said:
how far are you in the understanding of those steps thus far

that may have soudned rude, but I meant the steps in which you need to pass the values form the client to the server and thus back again.

apologies if that was taken the wrong way!

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
Thanks, but no need to apologise, I knew what you meant.

Cheers !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top