
July 22nd, 2004, 12:13 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Time spent in forums: 1 h 11 m 30 sec
Reputation Power: 0
|
|
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""> </td></tr></table></td>"
i=i+1
If i>(scPrdRow-1) then
response.write "</TR>"
End If
loop
End If %>
<% end if %>
</table>
|