<% ' Comersus 4.2x Sophisticated Cart ' Developed by Rodrigo S. Alhadeff ' Dic-2002 ' Open Source License can be found at License.txt ' http://www.comersus.com m ' Details: list active categories on the store. If is leaf category, list products %> <% dim mySQL, connTemp, rsTemp, pIdCategory, pCategoryDesc, totalPages, count call saveCookie() on error resume next ' set affiliate pIdAffiliate=getUserInput(request.querystring("idAffiliate"),4) if isNumeric(pIdAffiliate)then session("idAffiliate")= pIdAffiliate end if ' get settings pDefaultLanguage = getSettingKey("pDefaultLanguage") pStoreFrontDemoMode = getSettingKey("pStoreFrontDemoMode") pCurrencySign = getSettingKey("pCurrencySign") pDecimalSign = getSettingKey("pDecimalSign") pCompany = getSettingKey("pCompany") pCompanyLogo = getSettingKey("pCompanyLogo") pAuctions = getSettingKey("pAuctions") pListBestSellers = getSettingKey("pListBestSellers") pNewsLetter = getSettingKey("pNewsLetter") pPriceList = getSettingKey("pPriceList") pStoreNews = getSettingKey("pStoreNews") pOneStepCheckout = getSettingKey("pOneStepCheckout") pCategoriesAlphOrder = getSettingKey("pCategoriesAlphOrder") ' defined 10 records per page const numPerPage = 10 if request.queryString("curPage") = "" then curPage = 1 else curPage = getUserInput(request.queryString("curPage"),4) end if pIdCategory = getUserInput(request.querystring("idCategory"),4) ' get category tree if pIdCategory<>"" then dim arrCategories(100,2) indexCategories = 0 pUrlString = Cstr("") pIdCategory2=pIdCategory ' load category array with all categories until parent do while pIdCategory2>1 mySQL="SELECT categoryDesc, idCategory, idParentcategory, imageCategory FROM categories WHERE idCategory=" & pIdCategory2 call getFromDatabase (mySql, rsTemp, "listCategoriesAndProducts") if rstemp.eof then response.redirect "message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_listcategoriesandproducts_6") ) end if pCategoryDescSw = rsTemp("categoryDesc") pIdCategorySw = rsTemp("idCategory") pImageCategory = rsTemp("imageCategory") call switchCategoryLanguage(session("language"), pIdCategorySw, pCategoryDescSw) pIdCategory2 = rsTemp("idParentCategory") arrCategories(indexCategories,0) = pCategoryDescSw arrCategories(indexCategories,1) = pIdCategorySw indexCategories = indexCategories + 1 loop end if 'idParentCategory ' get child categories if pIdCategory="" then mySQL="SELECT idCategory, categoryDesc, idParentCategory, imageCategory FROM categories WHERE idParentCategory=1 AND idCategory<>1 AND active=-1" else mySQL="SELECT idCategory, categoryDesc, idParentCategory, imageCategory FROM categories WHERE idParentCategory=" &pIdCategory& " AND idCategory<>1 AND active=-1" end if if pCategoriesAlphOrder="-1" then mySql=mySql&" ORDER BY categoryDesc" else mySql=mySql&" ORDER BY displayOrder" end if call getFromDatabase (mySql, rsTemp, "listCategoriesAndProducts") ' no categories defined in the store if rstemp.eof and pIdCategory="" then response.redirect "message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_listcategoriesandproducts_1") ) end if %><% ' leaf category, list all products if rstemp.eof then mySQL="SELECT products.idProduct, description, price, bTobPrice, smallImageUrl, stock FROM products, categories_products WHERE products.idProduct=categories_products.idProduct AND categories_products.idCategory="& pIdCategory&" AND listHidden=0 AND active=-1 ORDER BY description" call getFromDatabasePerPage(mySql, rstemp,"listCategoriesAndProducts") %>
<% response.write dictLanguage.Item(Session("language")&"_listcategoriesandproducts_2") for f=indexCategories-1 to 0 step -1 response.write " > " & "" & arrCategories(f,0) &"" next %>

<% if rstemp.eof then response.write dictLanguage.Item(Session("language")&"_listcategoriesandproducts_4") else rstemp.moveFirst rstemp.pageSize = numPerPage totalPages = rstemp.PageCount rstemp.absolutePage = curPage do while not rstemp.eof and count < rstemp.pageSize pIdProduct = rstemp("idProduct") pDescription = rstemp("description") pPrice = rstemp("price") pBtoBPrice = rstemp("bToBPrice") pSmallImageUrl = rstemp("smallImageUrl") pStock = rstemp("stock") call switchProductsLanguage(session("language"), pIdProduct, pDetails, pDescription) %><% count = count + 1 rstemp.moveNext loop %>

<%response.write(dictLanguage.Item(Session("language")&"_listproductsbysupplier_4") & curPage & dictLanguage.Item(Session("language")&"_listproductsbysupplier_5") & TotalPages & "

")%> <% if curPage > 1 then response.write("") end if if cInt(curPage) <> cInt(TotalPages) then response.write("") end if %>

<% end if ' eof for products else ' is not leaf category %>

<% if pIdCategory<>"" then response.write dictLanguage.Item(Session("language")&"_listcategoriesandproducts_2") for f=indexCategories-1 to 0 step -1 response.write " > " & "" & arrCategories(f,0) &"" next else response.write dictLanguage.Item(Session("language")&"_listcategoriesandproducts_5") end if %>

<% do while not rstemp.eof pIdCategory = rstemp("idCategory") pCategoryDesc = rstemp("categoryDesc") pIdParentCategory = rstemp("idParentCategory") pImageCategory = rstemp("imageCategory") call switchCategoryLanguage(session("language"), pIdCategory, pCategoryDesc) %> <%if trim(pImageCategory)<>"" then%> <%end if%> <%response.write pCategoryDesc%>

<% rstemp.moveNext loop end if call closeDb() %>