<%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% Dim categoryID, categoryName, categoryParentID, categoryNoDiscount, categoryNoOrder, categoryDiscountPercent, categoryLink Dim cName, scName Dim searchQuery Dim pageMaxRecords Dim pageCount Dim pageCurrent Dim noRecords Dim currentItemsStart, currentItemsEnd pageMaxRecords = session("maxproductsReturned") if not isNumberValid(pageMaxRecords) then pageMaxRecords = 5 pageCurrent = request.queryString("p") if not isNumberValid(pageCurrent) then pageCurrent = 1 else pageCurrent = cInt(pageCurrent) end if categoryID = request.queryString("cID") if not isNumberValid(categoryID) then categoryID = 0 else categoryParentID = lookUpItem("tblCategory", "parentID", "categoryID", categoryID) end if if not isNumberValid(categoryParentID) then response.redirect "default.asp?r=c1" returnPage = server.URLencode("categories.asp?cID=" & categoryID) lookupCategoryDiscount false, categoryID, categoryName, categoryNoDiscount, categoryNoOrder, categoryDiscountPercent categoryLink = "" & categoryName & "" Dim pageInfoExists pageInfoExists = false Sub listcategories() if dMode <> true then on error resume next Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open dbConnectionStr SQLQuery = "SELECT categoryID, categoryName, categoryDescription FROM tblCategory WHERE parentID=0 ORDER BY categoryName;" Set ds = objConn.Execute(SQLQuery) end sub Sub listSubcategories() if dMode <> true then on error resume next Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open dbConnectionStr if isNumberValid(session("eCart_membershipID")) AND session("eCart_membershipID") > 0 then SQLQuery = "SELECT tblCategory.categoryID, tblCategory.categoryName, tblCategory.categoryShortDescription, tblCategory.categoryImage FROM tblCategory INNER JOIN tblMembershipDiscounts ON tblCategory.categoryID = tblMembershipDiscounts.categoryID WHERE (((tblCategory.parentID)=" & categoryID & ") AND ((tblMembershipDiscounts.membershipID)=" & session("eCart_membershipID") & ") AND ((tblMembershipDiscounts.hidden)=" & prepBoolean("false") & ")) ORDER BY tblCategory.categoryName;" else SQLQuery = "SELECT categoryID, categoryName, categoryShortDescription, categoryImage FROM tblCategory WHERE parentID=" & categoryID & " AND hidden=" & prepBoolean("false") & " ORDER BY categoryName;" end if Set ds = objConn.Execute(SQLQuery) end sub Sub listproductsInCategory() if dMode <> true then on error resume next Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open dbConnectionStr if session("preOrder_Display") = true then if session("stock_LowDisplay") = true then if isNumeric(session("eCart_membershipID")) AND session("eCart_membershipID") > 0 then ' Member query SQLQuery = "SELECT tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName, tblMembershipDiscounts.adjustmentType, tblMembershipDiscounts.amount, tblMembershipDiscounts.noOrder, tblMembershipDiscounts.noDiscount FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) INNER JOIN tblMembershipDiscounts ON tblProducts.productID = tblMembershipDiscounts.productID WHERE tblProducts_Categories.categoryID=" & categoryID & " AND (tblMembershipDiscounts.membershipID=" & session("eCart_membershipID") & " AND tblMembershipDiscounts.hidden=" & prepBoolean("false") & ") ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" else ' Non member query SQLQuery = "SELECT tblCategory.noOrder, tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) WHERE tblProducts_Categories.categoryID=" & categoryID & " AND tblProducts.productOnline=" & prepBoolean("true") & " AND tblCategory.hidden=" & prepBoolean("false") & " ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" end if else if isNumeric(session("eCart_membershipID")) AND session("eCart_membershipID") > 0 then ' Member query SQLQuery = "SELECT tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName, tblMembershipDiscounts.adjustmentType, tblMembershipDiscounts.amount, tblMembershipDiscounts.noOrder, tblMembershipDiscounts.noDiscount FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) INNER JOIN tblMembershipDiscounts ON tblProducts.productID = tblMembershipDiscounts.productID WHERE ([stock_Level]>=[stock_LowLevel]) AND tblProducts_Categories.categoryID=" & categoryID & " AND (tblMembershipDiscounts.membershipID=" & session("eCart_membershipID") & " AND tblMembershipDiscounts.hidden=" & prepBoolean("false") & ") ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" else ' Non member query SQLQuery = "SELECT tblCategory.noOrder, tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) WHERE ([stock_Level]>=[stock_LowLevel]) AND tblProducts_Categories.categoryID=" & categoryID & " AND tblProducts.productOnline=" & prepBoolean("true") & " AND tblCategory.hidden=" & prepBoolean("false") & " ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" end if end if else ' Remove unreleased products if session("stock_LowDisplay") = true then if isNumeric(session("eCart_membershipID")) AND session("eCart_membershipID") > 0 then ' Member query SQLQuery = "SELECT tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName, tblMembershipDiscounts.adjustmentType, tblMembershipDiscounts.amount, tblMembershipDiscounts.noOrder, tblMembershipDiscounts.noDiscount FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) INNER JOIN tblMembershipDiscounts ON tblProducts.productID = tblMembershipDiscounts.productID WHERE (dateAvailable<" & prepDate(date()) & " OR dateAvailable IS NULL) AND tblProducts_Categories.categoryID=" & categoryID & " AND (tblMembershipDiscounts.membershipID=" & session("eCart_membershipID") & " AND tblMembershipDiscounts.hidden=" & prepBoolean("false") & ") ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" else ' Non member query SQLQuery = "SELECT tblCategory.noOrder, tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) WHERE (dateAvailable<" & prepDate(date()) & " OR dateAvailable IS NULL) AND tblProducts_Categories.categoryID=" & categoryID & " AND tblProducts.productOnline=" & prepBoolean("true") & " AND tblCategory.hidden=" & prepBoolean("false") & " ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" end if else if isNumeric(session("eCart_membershipID")) AND session("eCart_membershipID") > 0 then ' Member query if databaseType = 3 then SQLQuery = "SELECT tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName, tblMembershipDiscounts.adjustmentType, tblMembershipDiscounts.amount, tblMembershipDiscounts.noOrder, tblMembershipDiscounts.noDiscount FROM tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID INNER JOIN tblMembershipDiscounts ON tblProducts.productID = tblMembershipDiscounts.productID WHERE (dateAvailable<" & prepDate(date()) & " OR dateAvailable IS NULL) AND (stock_Level)>=(stock_LowLevel) AND tblProducts_Categories.categoryID=" & categoryID & " AND tblMembershipDiscounts.membershipID=" & session("eCart_membershipID") & " AND tblMembershipDiscounts.hidden=" & prepBoolean("false") & " ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" else SQLQuery = "SELECT tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName, tblMembershipDiscounts.adjustmentType, tblMembershipDiscounts.amount, tblMembershipDiscounts.noOrder, tblMembershipDiscounts.noDiscount FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) INNER JOIN tblMembershipDiscounts ON tblProducts.productID = tblMembershipDiscounts.productID WHERE (dateAvailable<" & prepDate(date()) & " OR dateAvailable IS NULL) AND ([stock_Level]>=[stock_LowLevel]) AND tblProducts_Categories.categoryID=" & categoryID & " AND (tblMembershipDiscounts.membershipID=" & session("eCart_membershipID") & " AND tblMembershipDiscounts.hidden=" & prepBoolean("false") & ") ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" end if else ' Non member query if databaseType = 3 then SQLQuery = "SELECT tblCategory.noOrder, tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) WHERE (dateAvailable<" & prepDate(date()) & " OR dateAvailable IS NULL) AND ((stock_Level)>=(stock_LowLevel)) AND tblProducts_Categories.categoryID=" & categoryID & " AND tblProducts.productOnline=" & prepBoolean("true") & " AND tblCategory.hidden=" & prepBoolean("false") & " ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" else SQLQuery = "SELECT tblCategory.noOrder, tblProducts.productID, tblProducts.canOrder, tblProducts.productName, tblProducts.shortDescription, tblProducts.imageThumbnail, tblProducts.salePrice, tblProducts.retailPrice, tblProducts.stock_Level, tblProducts.stock_LowLevel, tblProducts.stock_LowNoOrder, tblProducts.dateAvailable, tblProducts.status_mode, tblProducts.downloadable, tblCategory.categoryName, tblCategory.categoryID, tblCategory.categoryName FROM ((tblProducts LEFT JOIN tblProducts_Categories ON tblProducts.productID = tblProducts_Categories.productID) LEFT JOIN tblCategory ON tblProducts_Categories.categoryID = tblCategory.categoryID) WHERE (dateAvailable<" & prepDate(date()) & " OR dateAvailable IS NULL) AND ([stock_Level]>=[stock_LowLevel]) AND tblProducts_Categories.categoryID=" & categoryID & " AND tblProducts.productOnline=" & prepBoolean("true") & " AND tblCategory.hidden=" & prepBoolean("false") & " ORDER BY tblProducts.displayOrderGroup, tblProducts.productName;" end if end if end if end if if databaseType = 3 then SQLQuery = replace(SQLQuery, "[stock_Level]", "(stock_level)") SQLQuery = replace(SQLQuery, "[stock_LowLevel]", "(stock_LowLevel)") end if Set ds = server.createObject("ADODB.Recordset") ds.PageSize = pageMaxRecords ds.CacheSize = pageMaxRecords if databaseType = 3 then ds.CursorLocation = 3 ds.Open SQLQuery, objConn, 3, 1, &H0001 noRecords = ds.recordCount pageCount = ds.PageCount If pageCurrent > pageCount then pageCurrent = pageCount If pageCurrent < 1 then pageCurrent = 1 end sub %> <% =session("storePageTitle") %>
<% Dim categoryImage categoryImage = lookupItem("tblCategory","categoryImage","categoryID",request.queryString("cID")) if isTextValid(categoryImage) then %>
<% =returncategoryName(request.queryString("cID")) %>
<% else %> <% =returncategoryName(request.queryString("cID")) %>
<% end if if session("displaycategoryDescriptions") = true then if request.queryString("scID") <> "" then s = returncategoryDescription(request.queryString("scID"), true) else s = returncategoryDescription(request.queryString("cID"), false) end if if s <> "" then send "" & replace(s, chr(10), "
") & "

" end if if categoryID = 0 then listcategories() if not ds.bof AND not ds.eof then i = 0 %><% do until ds.eof i = i + 1 if i > 2 then i = 1 displayCategory ds("categoryID"), ds("categoryName"), "", ds("categoryDescription"), i ds.moveNext loop %>
<% else %> No categories exist. <% end if set ds = nothing objConn.close %> <% else ' list sub categories if none selected if categoryParentID >= 0 then listSubcategories() if not ds.bof AND not ds.eof then i = 0 %>
<% do until ds.eof i = i + 1 if i > 2 then i = 1 displayCategory ds("categoryID"), ds("categoryName"), ds("categoryImage"), ds("categoryShortDescription"), i ds.moveNext loop %>
<% pageInfoExists = true else pageInfoExists = false end if set ds = nothing objConn.close end if end if if categoryID > 0 then listproductsInCategory() if not ds.bof AND not ds.eof then ds.AbsolutePage = pageCurrent currentItemsStart = ((pageCurrent-1)*pageMaxRecords)+1 currentItemsEnd = ((pageCurrent)*pageMaxRecords) if currentItemsEnd > noRecords then currentItemsEnd = noRecords pageCurrent = cInt(pageCurrent) listPageDetails() %>

<% k = 0 j = 0 do while j < pageMaxRecords AND not ds.EOF k = k + 1 if k > 2 then k = 1 ' Work out if there is any member pricing if isNumberValid(session("eCart_membershipID")) AND session("eCart_membershipID") > 0 then i = returnproductPrice(1, cCur(ds("salePrice")), session("eCart_membershipID"), session("eCart_globalDiscountRate"), ds("adjustmentType"), cCur(ds("amount")), ds("noDiscount"), categoryNoDiscount, categoryDiscountPercent) if categoryNoOrder = true OR ds("noOrder") then m = false else m = true end if displayProduct ds("productID"), m, ds("productName"), ds("shortDescription"), categoryID, false, "", ds("imageThumbnail"), cCur(i), cCur(ds("retailPrice")), ds("stock_Level"), ds("stock_LowLevel"), ds("stock_LowNoOrder"),ds("dateAvailable"), ds("status_mode"), ds("downloadable"), k else i = returnproductPrice(1, ds("salePrice"), 0, session("eCart_globalDiscountRate"), 0, 0, false, categoryNoDiscount, categoryDiscountPercent) if ds("canOrder") = false or ds("noOrder") = true then m = false else m = true end if displayProduct ds("productID"), m, ds("productName"), ds("shortDescription"), categoryID, false, "", ds("imageThumbnail"), cCur(i), cCur(ds("retailPrice")), ds("stock_Level"), ds("stock_LowLevel"), ds("stock_LowNoOrder"),ds("dateAvailable"), ds("status_mode"), ds("downloadable"), k end if j = j + 1 ds.moveNext loop %>
<% listPageDetails() else if pageInfoExists = false then %>
<% if categoryParentID = 0 then %> No products or sub categories exist within this Category. <% else %> No products exist within this Sub Category. <% end if end if end if set ds = nothing objConn.close end if sub listPageDetails() if dMode <> true then on error resume next %>
Product <% =currentItemsStart %> to <% =currentItemsEnd %> of <% =noRecords %>
Page: <% If pageCurrent > 1 then %>  < <% end if k = pageCount if k > 25 then k = 25 for i = 1 to k If i = pageCurrent then %>  <% =i %><% else %>  <% =i %><% end if next 'i If pageCurrent < pageCount then %>  > <% end if end sub %>



<% ' ERROR REPORTING - DON'T REMOVE! if dMode <> true AND err.number <> 0 then reportError err.number, err.description, err.source, "" end if %>