Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 Customization
 Simple Price Search Code
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mxu8808
Starting Member

25 Posts

Posted - March 28 2007 :  21:04:38  Show Profile  Visit mxu8808's Homepage  Reply with Quote
I need a simple price search at my site, say, at the left category. I need to put:
Search Price:
Under $20
$20 - $50
$51 - $100
$101- $150
Above $150
How can I do that? Can anybody provide me with a detail procedure or just a simple code. Many thanks.

seeker1
VP-CART New User

Australia
114 Posts

Posted - March 28 2007 :  22:04:58  Show Profile  Visit seeker1's Homepage  Reply with Quote
This little form invoking shopquery.asp will do the trick

<form method="post" action="shopquery.asp" name="formq">
Price <input class="searchfield" type="text" name="cprice" size="19"/>
<input type="submit" value="Search by price" class="submitbtn" />
</form>

You could replace text box with drop down list or price values.

See Guide to VP-ASP for more examples and techniques
www.hkprog.com/guide
Go to Top of Page

Happy
VP-CART New User

90 Posts

Posted - March 31 2007 :  15:54:32  Show Profile  Reply with Quote
Another way could be like what I have done (change the values as per your need):

In the shoppage_header.asp add this code in a suitable location (row of the table):
<td><form method="get" action="customsearch.asp">
<input type="hidden" name="sbytype" value="p">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" class="pad3"><select name="price">
<option value="" selected="selected">Price Range (US$):</option>
<option value="1">Under US$100</option>
<option value="2">US$100-$200</option>
<option value="3">US$200-$400</option>
<option value="4">US$400-$600</option>
<option value="5">US$600-$900</option>
<option value="6">US$900-$1500</option>
<option value="7">Over US$1500</option>
</select></td>
</tr>
<tr>
<td valign="top" align="left"><table width="147" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><input type="submit" id="button" name="button1" value="Search" ></td>
</tr>
</table></td>
</tr>
</table>
</form></td>

Then, create a special page customsearch.asp with this code:
<%@ Language=VBScript %>
<%Option Explicit%>
<!--#include file="shop$db.asp"-->
<!--#include file="shoprandomproducts.asp"-->

<%InitializeSystem%>
<%
dim i, j
dim whereok
Dim SearchFields
dim Fieldcount
dim strdistinct
dim tword, cat, keyword, price
price = Request.QueryString("price")
strdistinct="DISTINCTROW "

whereok=" AND "
dim strProductFields, tmpstr

tmpstr="select " & strdistinct & " p.catalogid from products p, prodcategories cc, prodcategories sc, categories c"
sql= " where cc.intcatalogid=p.catalogid and cc.intcategoryid=c.categoryid AND sc.intcatalogid=p.catalogid"
If price = "1" then
SQL = SQL & " AND p.cprice BETWEEN 0 AND 100"
End If
If price = "2" then
SQL = SQL & " AND p.cprice BETWEEN 100 AND 200"
End If
If price = "3" then
SQL = SQL & " AND p.cprice BETWEEN 200 AND 400"
End If
If price = "4" then
SQL = SQL & " AND p.cprice BETWEEN 400 AND 600"
End If
If price = "5" then
SQL = SQL & " AND p.cprice BETWEEN 600 AND 900"
End If
If price = "6" then
SQL = SQL & " AND p.cprice BETWEEN 900 AND 1500"
End If
If price = "7" then
SQL = SQL & " AND p.cprice > 1500"
End If

Sql=Sql & " AND hide=0"

if getconfig("xstocklow")<>"" then
lngCStock= clng(getconfig("xStockLow"))
SQL= SQL & " AND "
sql = sql & " cstock> " & lngcstock
end if


sql = sql & " order by " & getconfig("xSortProducts")


sql=tmpStr & sql
SetSess "SQL",SQL

if getconfig("xdebug")="Yes" then
debugwrite sql
end if

response.Redirect("shopdisplayproducts.asp?Search=Yes&sppp=6")
%>

Try this. Please note that I have cut and pasted this code from mine (which is tested and works well) but some tweaking may be needed if I have copied incorrectly.

Let me know how it works. The SQL is suitable for MySQL. If you want to see it in action, you may visit www.myfinestjewelry.com (the site is not launched yet).


Thanks,
Happy
Go to Top of Page

mxu8808
Starting Member

25 Posts

Posted - April 01 2007 :  10:38:19  Show Profile  Visit mxu8808's Homepage  Reply with Quote
Happy:

Yours is a drop down style for pricing search. It works great! I tested.

However, based on my site layout, I want a price search function exactly like the style below:
Under $20
$ 20-$100
$100-$200
Above $200
Please visit Wal-mart's Sam's Club site http://www.samsclub.com. Input "office" in the search box. At the search result page, you will see such a price search function at the left side.

It is not necessary to show how many items under $20 or between $100 -$200. I like this simple price function.

I visited your site. You did a very wonderful page design! Very very professional. Would you teach us how you edit the paging (add previous, next) and the code for category tree?

Many Thanks!
Go to Top of Page

Happy
VP-CART New User

90 Posts

Posted - April 01 2007 :  15:26:24  Show Profile  Reply with Quote
Sorry, I did not understand earlier what you wanted.

You could try this (I have not tested it at all but I believe it should not require more than a little bit of debugging, if at all):

In the shoppage_header.asp add this code in a suitable location (row of the table):
<td>
<a href="customsearch.asp?price=1>Under $20</a><br />
<a href="customsearch.asp?price=2>$21 - $50</a><br />
<a href="customsearch.asp?price=3>$51 - $100</a><br />
</td>

Then, create a special page customsearch.asp with this code:
<%@ Language=VBScript %>
<%Option Explicit%>
<!--#include file="shop$db.asp"-->
<!--#include file="shoprandomproducts.asp"-->

<%InitializeSystem%>
<%
dim i, j
dim whereok
Dim SearchFields
dim Fieldcount
dim strdistinct
dim tword, price
price = Request.QueryString("price")
strdistinct="DISTINCTROW "

whereok=" AND "
dim strProductFields, tmpstr

SQL="select " & strdistinct & " catalogid from products"
If price = "1" then
SQL = SQL & " where p.cprice BETWEEN 0 AND 20"
End If
If price = "2" then
SQL = SQL & " where p.cprice BETWEEN 21 AND 50"
End If
If price = "3" then
SQL = SQL & " AND p.cprice BETWEEN 51 AND 100"
End If

Sql=Sql & " AND hide=0"

if getconfig("xstocklow")<>"" then
lngCStock= clng(getconfig("xStockLow"))
SQL= SQL & " AND "
sql = sql & " cstock> " & lngcstock
end if


sql = sql & " order by " & getconfig("xSortProducts")


sql=tmpStr & sql
SetSess "SQL",SQL

if getconfig("xdebug")="Yes" then
debugwrite sql
end if

response.Redirect("shopdisplayproducts.asp?Search=Yes&sppp=6")
%>

You may extend this to all the price ranges you want.

Regarding the top drop down menu, this is a very good article with examples at http://www-adele.imag.fr/users/Didier.Donsez/cours/exemplescourstechnoweb/js_menu/smith_menu.html. I have built based on this.



Thanks,
Happy
Go to Top of Page

Happy
VP-CART New User

90 Posts

Posted - April 01 2007 :  15:28:40  Show Profile  Reply with Quote
And I forgot to mention, thanks for the compliment!

Thanks,
Happy
Go to Top of Page

mxu8808
Starting Member

25 Posts

Posted - April 01 2007 :  23:30:49  Show Profile  Visit mxu8808's Homepage  Reply with Quote
Happy:

Thank you very much! You are really helpful!

Have a good one! Michael
Go to Top of Page

mxu8808
Starting Member

25 Posts

Posted - April 01 2007 :  23:34:29  Show Profile  Visit mxu8808's Homepage  Reply with Quote
Happy:

Again, the link you provide is no more connected. Plus, it is French. I don't know French. Is there other example codes I can read? or your experience.

Thanks!

[Regarding the top drop down menu, this is a very good article with examples at http://www-adele.imag.fr/users/Didier.Donsez/cours/exemplescourstechnoweb/js_menu/smith_menu.html. I have built based on this.]
Go to Top of Page

Happy
VP-CART New User

90 Posts

Posted - April 02 2007 :  08:24:55  Show Profile  Reply with Quote
Sorry about that.

Please try this: http://www.sirendesign.net/smithmenu2.htm.

Thanks,
Happy
Go to Top of Page

mxu8808
Starting Member

25 Posts

Posted - April 02 2007 :  10:57:06  Show Profile  Visit mxu8808's Homepage  Reply with Quote
Happy:

The link does not work too.

Thanks.

Michael
Go to Top of Page

Happy
VP-CART New User

90 Posts

Posted - April 02 2007 :  12:01:35  Show Profile  Reply with Quote
Both links work. Do not click the link from this page (it takes the dot at the end as well). Copy and paste in the browser ensuring the dot is not there.

Thanks,
Happy
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00