VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 Customization
 Product count code....like ..toys (32) etc..
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

billsingh
VP-ASP New User

56 Posts

Posted - July 21 2002 :  18:32:00  Show Profile  Visit billsingh's Homepage  Reply with Quote
Hi all,
Thanks everyone else for contributing to this forum and make it the best vpasp forum. Here is my contribution.

If you want to make left hand categories navigation look like the following...use this code.

Clothes (2)
Toys (39) Subcats....
Travel (2)

Step 1
Create new field in category table called prodcount (numeric or int)

Step 2
Create the file called updatecat.asp. Run this file everytime you add new products in your database (to update count).Paste the following code and save the file as updatecat.asp
<%
Dim Conn, rs, MySQL
Set Conn = Server.CreateObject("ADODB.Connection")
conn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../database/shopping450.mdb")
'MySQL = "SELECT * FROM orders where orderid =" & Request.Form("orderno")
MySQL = "SELECT * FROM categories"
Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open MySQL, conn, 3, 3
Do While not rs.EOF

Set rs1 = Server.CreateObject("ADODB.Recordset")
MySQL1 = "Select * FROM prodcategories where intcategoryid=" & rs("categoryid")
rs1.Open MySQL1, conn, 3, 3

'Response.Write rs("catdescription") & " = " & rs1("Productcount") & "<br>"
Response.Write rs("catdescription") & " = " & rs1.RecordCount & "<br>"
rs("prodcount") = rs1.RecordCount
rs1.close
set rs1 = nothing

rs.Update
rs.movenext
loop


rs.close
set conn = nothing
set rs = nothing

%>

Step 3
open shopproductsubs.asp. Locate the subroutine NavigateShowCategories look for the following.
if hasSubcategory ="" then
mylink="<a HREF=""shopdisplayproducts.asp?id=" & cid & "&cat=" & Server.URLEncode(name) & """>" & name & "</a>"
else
mylink="<a HREF=""shopdisplaycategories.asp?id=" & cid & "&cat=" & Server.URLEncode(name) & """>" & name & "...</a>"
end if

Replace them by the folloiwng lines.
if hasSubcategory ="" then
mylink="<a HREF=""shopdisplayproducts.asp?id=" & cid & "&cat=" & Server.URLEncode(name) & """>" & name & " (" & catrs("prodcount") & ")</a>"
else
mylink="<a HREF=""shopdisplaycategories.asp?id=" & cid & "&cat=" & Server.URLEncode(name) & """>" & name & " (" & catrs("prodcount") & ") Subcats...</a>"
end if

Run updatecat.asp in your browser and you are set.

Thnaks
Bill Singh

  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000