Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 22nd, 2004, 12:13 PM
ASPeon ASPeon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 ASPeon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 30 sec
Reputation Power: 0
Arrow Customizing shopping cart: display random category preview items

I am working on customizing an "off the shelf" shopping cart for a client. The shopping cart uses the same page to display categories and sub-categories. What my client wants is for the categories that have sub-categories to display 4 random products from within the sub-category.

I have looked at the code, and can't figure out what exactly I need to do and where. It has been almost a year since I have done any ASP coding, and I am just drawing a blank. Of course, like all of us, I am under a deadline to get this done ASAP, so I appreciate any help and insight. Or, if you are willing to customize the code for me (for a reasonable fee, of course), I am open to that as well. Here is the part of the cart where the categories are displayed:
Code:
 
<% if rstemp.eof then ' leaf category, list all products
 mySQL="SELECT idCategory,categoryDesc,[image],idParentCategory FROM categories WHERE idcategory="& pIdCategory & "AND iBTOhide=0 " & pcv_strTemp & "  ORDER BY priority, categoryDesc ASC;"
 set rstemp2=Server.CreateObject("ADODB.Recordset")	 
  rsTemp2.Open mySQL, Conntemp, adOpenStatic, adLockReadOnly, adCmdText
  if err.number <> 0 then  
	call closeDb()
  response.redirect "techErr.asp?error="&Server.UrlEncode("Error db viewCat_h. Error: "&err.description)
  end If
  
  mySQL="Select POrder from categories_products where idCategory="& pIdCategory
  set rs4=connTemp.execute(mySQL)
  UONum=0
  do while not rs4.eof
  if rs4("POrder")<>"" then
  UONum=UONum+Cint(rs4("POrder"))
  end if
  rs4.MoveNext
  loop
  
  ProdSort="" & request("prodsort")
  if ProdSort<>"" then
  else
  if UONum>0 then
  ProdSort="19"
  else
  ProdSort="" & PCOrd
  end if
  end if
  
  if ProdSort="" then
  ProdSort="0"
  end if
  
  select case ProdSort
  Case "19": mySQL1 = " ORDER BY categories_products.POrder Asc"
  Case "0": mySQL1 = " ORDER BY products.SKU Asc"
  Case "1": mySQL1 = " ORDER BY products.description Asc"  
  Case "2": 
  If Session("customerType")=1 then
  mySQL1 = " ORDER BY products.btoBprice desc, products.price Desc"
  else
  mySQL1 = " ORDER BY products.price Desc"
  End if  
  Case "3":
  If Session("customerType")=1 then
  mySQL1 = " ORDER BY products.bToBprice Asc, products.price Asc"  
  else
  mySQL1 = " ORDER BY products.price Asc"  
  end if
  end select
  
	  
 mySQL="SELECT products.idProduct, products.description, products.price, products.listprice, products.listhidden, products.serviceSpec, products.bToBPrice, products.smallImageUrl,products.noprices,products.  pcprod_HideBTOPrice FROM products, categories_products WHERE products.idProduct=categories_products.idProduct AND categories_products.idCategory="& pIdCategory&" AND active=-1 AND configOnly=0 and removed=0 " & mySQL1
 set rstemp2=Server.CreateObject("ADODB.Recordset")	 
 
 rstemp2.CacheSize=iPageSize
 rstemp2.PageSize=iPageSize
   
  rsTemp2.Open mySQL, Conntemp, adOpenStatic, adLockReadOnly, adCmdText
 
 if err.number <> 0 then  
  call closeDb()
  response.redirect "techErr.asp?error="&Server.UrlEncode("Error db viewCat_h. Error: "&err.description)
 end If
 dim iPageCount
 iPageCount=rstemp2.PageCount
 If Cint(iPageCurrent) > Cint(iPageCount) Then iPageCurrent=iPageCount
 If iPageCurrent < 1 Then iPageCurrent=1
 'rstemp.MoveFirst
 rstemp2.AbsolutePage=iPageCurrent
	%>
		 
<table width="<%=scprdTableWidth%>" border="0" cellpadding="2" cellspacing="0">
  <tr valign="top">
  <td colspan="<%=scPrdRow%>" valign="top">
  <font face="<%=FFType%>"  color="<%=FColor%>" size="2"><b>
	 <% response.write dictLanguage.Item(Session("language")&"_viewCat_P_2")
   for f=indexCategories-1 to 0 step -1
	If arrCategories(f,2)="1" Then
	 response.write "<a href='viewCat_h.asp?idCategory=" &arrCategories(f,1) & "'><font color="""& Link &""">" & arrCategories(f,0) &"</font></a>"
	Else
	 response.write " > " & "<a href='viewCat_h.asp?idCategory=" &arrCategories(f,1) & "'><font color="""& Link &""">" & arrCategories(f,0) &"</font></a>"
	End If
   next %></b></font></td></tr>
   <%if (LDesc<>"") and (HideDesc<>"1") then%>
   <tr><td colspan="<%=scPrdRow%>"><font face="<%=FFType%>"  color="<%=FColor%>" size="2"><%=LDesc%></font></td></tr>
   <%end if%>
  <%if (not rstemp2.eof) and (HideSortPro<>"1") then%>
  <tr><td colspan="<%=scPrdRow%>"><img src="images/cleardot.gif" height="10" width="1"></td></tr>
	<tr valign="top">
  <td colspan="<%=scPrdRow%>" align="right">
	  <form action="viewCat_h.asp?idcategory=<%=pidcategory%>" method="post" style="margin-top:0px; margin-bottom:0px;">
<p align="right">
<font face="<%=FFType%>"  color="<%=FColor%>" size="2"><%=dictLanguage.Item(Session("language")&"_viewCatOrder_5")%></font> <select name="prodSort" onChange="javascript:if (this.value != '') {this.form.submit();}">
<%if UONum>0 then%>			
			<option value="19" <%if ProdSort="19" then%>selected<%end if%>><%=dictLanguage.Item(Session("language")&"_viewCatOrder_6")%></option>
<%end if%>						
			<option value="0" <%if ProdSort="0" then%>selected<%end if%>><%=dictLanguage.Item(Session("language")&"_viewCatOrder_1")%></option>
			<option value="1" <%if ProdSort="1" then%>selected<%end if%>><%=dictLanguage.Item(Session("language")&"_viewCatOrder_2")%></option>
			<option value="2" <%if ProdSort="2" then%>selected<%end if%>><%=dictLanguage.Item(Session("language")&"_viewCatOrder_3")%></option>
   <option value="3" <%if ProdSort="3" then%>selected<%end if%>><%=dictLanguage.Item(Session("language")&"_viewCatOrder_4")%></option>
		</select>
</form>
</td></tr>
  <%end if%>
  <tr><td colspan="<%=scPrdRow%>"><img src="images/cleardot.gif" height="15" width="1"></td></tr>
  <tr valign="top">
	<% if rstemp2.eof then %>
	 <td><font face="<%=FFType%>" color="<%=FColor%>" size="2"> 
	 <% response.write dictLanguage.Item(Session("language")&"_viewCat_P_4")%>
	 </font></td> 
	<% else
	do while not rstemp2.eof and count < rstemp2.pageSize
   
	pidProduct=rstemp2(0)
	pDescription=rstemp2("description")   
	pPrice=rstemp2("price")
	pListPrice=rstemp2("listprice")
	pListHidden=rstemp2("listhidden")   
	pBtoBPrice=rstemp2("bToBPrice")   
	pSmallImageUrl=rstemp2("smallImageUrl")
	pserviceSpec=rstemp2("serviceSpec")
	pnoprices=rstemp2("noprices")
	if pnoprices<>"" then
	else
	pnoprices=0
	end if
	pcv_intHideBTOPrice=rstemp2("pcprod_HideBTOPrice")
	if pcv_intHideBTOPrice<>"" then
	  else
	  pcv_intHideBTOPrice="0"
	end if
	<td height="2" valign="bottom"> 
	  <!----------------- product table --------------------------------->
  <table width="125" height="230" border="0" cellpadding="4" cellspacing="0">
		<tr><td width="100%" valign="bottom" align="center"> 
		  <%if pSmallImageUrl<>"" then%>
	 <a href='viewPrd.asp?idcategory=<%=pIdCategory%>&idproduct=<%=pIdProduct%>'> 
		   <img src="catalog/<%response.write pSmallImageUrl%>" border="0"></a> 
		  <% else %>
	 <a href='viewPrd.asp?idcategory=<%=pIdCategory%>&idproduct=<%=pIdProduct%>'> 
		   <img src="catalog/no_image.gif" width="50" height="50" border="0" ></a>
	<%end if %>
		  </td>
		</tr>
		<tr valign="top"><td height="5" valign="bottom"></td></tr>
		<tr valign="top">
  <td width="100%" height="125" align="center" valign="top">
   <table border="0" align="center" cellpadding="1" cellspacing="0">
   <tr><td align="center" valign="top">
   <font face="<%=FFType%>"  color="<%=FColor%>" size="2"><b><%response.write pDescription%></b></font>
   </td></tr>
   <tr><td valign="top" align="center">
		<font face="<%=FFType%>"  color="<%=FColor%>" size="2">
	  <% if (pPrice>0) and (pcv_intHideBTOPrice<>"1") then
	   response.write dictLanguage.Item(Session("language")&"_prdD1_1") & " "
	   response.write scCurSign & money(pPrice)%><br>
	   <%if (pListPrice-pPrice)>0 AND plistHidden<0 AND session("customerType")<>1 then %><font color="<%=MType%>"><%response.write dictLanguage.Item(Session("language")&"_prdD1_2")%><%response.write scCurSign & money(pListPrice-pPrice)%></font><br>
	   <% end if
	  end if %>
	  
	  <% if (pBtoBPrice>"0") and (session("customerType")="1") and (pcv_intHideBTOPrice<>"1") then
							response.write dictLanguage.Item(Session("language")&"_prdD1_4")& " "
	   response.write scCurSign & money(pbToBPrice)%></font><br>
			   <%end if %>
	</font>
	 </td>
	 </tr>
	 <tr><td align="center">
				 <a href='viewPrd.asp?idcategory=<%=pIdCategory%>&idproduct=<%=pIdProduct%>'>
	 <img src="<%=rslayout("morebtn")%>" hspace="0" vspace="5" border="0"></a>
	 </td>
	 </tr>
	 </table>
   </td>
		</tr>
	  </table>
<!---------------- End if product table --------------------------->
 </td>
  <% i=i + 1
  If i > (scPrdRow-1) then 
   response.write "</TR><TR>"
   i=0
  End If
  iRecordsShown=iRecordsShown + 1
  count=count + 1
 rsTemp2.movenext
 loop 
 If i<>0 then
  do until i>(scPrdRow-1) 
   response.write "<td height=""2"" valign=""bottom""><!----------------- product table ---------------------------------><table width=""125"" border=""0"" cellspacing=""0"" cellpadding=""4"" height=""200""><tr valign=""top""><td height=""116"" width=""125"" valign=""bottom"">&nbsp;</td></tr></table></td>"
   i=i+1
   If i>(scPrdRow-1) then
	response.write "</TR>"
   End If
  loop
 End If %>
 <% end if %>
 </table>
 

Reply With Quote
  #2  
Old July 22nd, 2004, 12:15 PM
ASPeon ASPeon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 ASPeon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 30 sec
Reputation Power: 0
Here is the rest of the code that displays the category products on the page:

Code:
  
<% else	' is not leaf category %>
 <% if sccatImages=1 then 
 response.write "<table width="""&sccatTableWidth&""" border=""0"" cellpadding=""2"" cellspacing=""0"">" 
  else %>
 <table width="<%=sccatTableWidth %>" border="0" cellspacing="0" cellpadding="2">
 <% end if %>
   <tr>
   <td><font face="<%=FFType%>"  color="<%=FColor%>" size="2"><b> 
	<% If pIdCategory<>"" then   
	response.write dictLanguage.Item(Session("language")&"_viewCat_P_2")
	for f=indexCategories-1 to 0 step -1
	 If arrCategories(f,2)="1" Then
	 response.write "<a href='viewCat_h.asp?idCategory=" &arrCategories(f,1) & "'><font color="""& Link &""">" & arrCategories(f,0) &"</font></a>"
	 Else
	 response.write " > " & "<a href='viewCat_h.asp?idCategory=" &arrCategories(f,1) & "'><font color="""& Link &""">" & arrCategories(f,0) &"</font></a>"
	 End If   
	next 
   else
	response.write dictLanguage.Item(Session("language")&"_viewCat_P_5")
   end if %>
   </b></font></td></tr>
   <%if (SDesc<>"") and (HideDesc<>"1") then%>
   <tr><td><font face="<%=FFType%>"  color="<%=FColor%>" size="2"><%=SDesc%></font></td></tr>
		 <%end if%>
<tr><td><img src="images/cleardot.gif" height="15" width="1"></td></tr>
<tr><td>
   <table width="100%" border="0" cellpadding="2" cellspacing="0">
					<tr valign="top"> 
	 <%   i=0 
	 iRecordsShown=0 
	 Do While iRecordsShown < iCatPageSize And NOT rsTemp.EOF
	  pidCategory=rstemp("idCategory")
	  pCategoryDesc=rstemp("categoryDesc")
	  pImage=rstemp("image")
	  CATSDesc=rstemp("SDesc") 
	  if pImage="" then
	  pImage="no_image.gif"
	  end if  
	  pidParentCategory=rstemp("idParentCategory")
	  %>
	  <td height="2" valign="bottom">
	  <% '==================inner table========== %>
		  <% if sccatImages=1 then
		  if scCatRow=1 then 
		  response.write "<table width=100% border=0 cellpadding=1 cellspacing=0>"%> 
		  <%else%>
		   <table width="150" height="150" border="0" cellpadding="2" cellspacing="0" align="center">
		  <% 
		  end if
		  else 
		   response.write "<table width=150 border=0 cellpadding=1 cellspacing=0>"
		  end if %>
		  <tr> 
		   <% if sccatImages=1 then
		   if scCatRow=1 then%>
		   
<td width="25%" height="100" valign="middle" align="center">
		   <a href='viewCat_h.asp?idCategory=<%response.write pidCategory%>'>
		   <img src="catalog/<%=pImage%>" border="0" hspace="5"></a>
		   </td>
		   <td valign="middle" width="75%">
		   <p> 
		   <font face="<%=FFType%>" color="<%=FColor%>" size="2">
		   <a href='viewCat_h.asp?idCategory=<%response.write pidCategory%>'>
		   <font color="<%=Link%>">
		   <% response.write pCategoryDesc%>
</font></a><br>
<%if CATSDesc<>"" then%><%=CATSDesc%><%else%>&nbsp;<%end if%></font></p></td>
<%else%>
<td height="100" align="center" valign="bottom">
		   <a href='viewCat_h.asp?idCategory=<%response.write pidCategory%>'>
		   <img src="catalog/<%=pImage%>" border="0"></a>
		   </td>
</tr>
		   <tr>
<td height="50" align="center" valign="top">
		   <font face="<%=FFType%>" color="<%=FColor%>" size="2">
		   <a href='viewCat_h.asp?idCategory=<%response.write pidCategory%>'>
		   <font color="<%=Link%>">
		   <% response.write pCategoryDesc%>
</font></a>
</font>
		   </td>
		   <%
		   end if
			else %>
		   <td align=left valign=bottom>
		   <font face="<%=FFType%>" color="<%=FColor%>" size="2">
		   <a href='viewCat_h.asp?idCategory=<%response.write pidCategory%>'>
		   <font color="<%=Link%>">
		   <% response.write pCategoryDesc%>
		   </font></a>
		   </font>
		   </td>
		   <% end if %>
		 </tr>
	  </table>
	  <% '==================inner table END===========%>
	  <% if sccatImages=1 then %>
	  <img src="images/spacer.gif" width="1" height="10" alt="">
	  <% end if %>
	  </td>
	  <% i=i + 1
	  If i > (scCatRow-1) then 
	  response.write "</TR><TR>"
	  i=0
	  End If
	  iRecordsShown=iRecordsShown + 1
	 rsTemp.movenext
	 loop
	 %>
   </table>
   </td>
  </tr>
 </table>
<% end If %>



Thanks in advance for any help!

Reply With Quote
  #3  
Old July 22nd, 2004, 12:58 PM
beercraft_asp's Avatar
beercraft_asp beercraft_asp is offline
Spell Breaker
ASP Free Novice (500 - 999 posts)
 
Join Date: May 2004
Posts: 990 beercraft_asp User rank is Lance Corporal (50 - 100 Reputation Level)beercraft_asp User rank is Lance Corporal (50 - 100 Reputation Level)beercraft_asp User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 8 h 33 m 42 sec
Reputation Power: 5
Send a message via AIM to beercraft_asp Send a message via MSN to beercraft_asp
Do you need to display random 4 products for specific sub-category???

Reply With Quote
  #4  
Old July 22nd, 2004, 05:19 PM
ASPeon ASPeon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 ASPeon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 30 sec
Reputation Power: 0
4 products are what fit in a row, and my customer would like to fill up each sub-category row. If possible, it would be best to have 4 on a row.

Yes, for each specific sub-category within a main/root category.


Thanks!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Customizing shopping cart: display random category preview items


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway