<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Display details for a specific product, including all ' : options. ' Product : CandyPress Store Frontend ' Version : 6.2 ' Modified : May 2007 ' Copyright: Copyright (C) 2010 Cavallo Communications, LLC. ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at http://www.candypress.com '******************************************************************************************** ' Date Description ' 12/02/06 Added display of stock level message to related products. ' 10/23/05 Added user exit ' 11/20/05 Corrected problem with price display in getProdRelated(); ' 04/05/06 Made option required indicator a language phrase ' 04/18/06 Added branding support ' 09/07/07 Added missing variable errMsg ' 09/12/07 Fixed getStockProd to work correctly with related products ' 05/22/08 Fixed showZeroOptionPrice so that options with zero cost will be hiddenimage ' 06/09/08 Added code to return to last displayed category page and sortorder ' 12/17/08 Added code to support multiple product image display ' 03/31/09 Added UOM display to product price ' 02/07/10 Removed tables, replaced with div - candythemes.com ' 03/10/10 Parens where being displayed when stock status was not diplayed ' 03/10/10 Related products was displaying the stock status for the viewed item '****************************************************************************************** Option explicit Response.Buffer = true %> <% 'Product dim IDProduct dim Description dim DescriptionLong dim Price dim Details dim relatedKeys dim listPrice dim smallImageURL dim imageURL dim Stock dim SKU dim fileName dim noShipCharge dim reviewAllow dim handlingFee dim wholesaleprice dim msrp dim map dim refurbished dim freight dim brand dim estimatedship dim idUOM dim minorder 'Options dim priceToAdd dim percToAdd 'Work Fields dim testMode dim revCount dim revSum dim numMandatoryOpt dim optSize dim errMsg dim sortField dim curPage dim idCategory dim userroles 'Database dim mySQL dim conntemp dim rstemp dim rstemp2 dim rsTemp3 dim cats 'Work dim idCust dim idOrder dim action '************************************************************************* selectedLang = Request.form("language") if len(selectedLang) = 2 then session("language") = selectedLang Response.cookies("language") = selectedLang Response.Cookies("language").expires = dateAdd("d",30,now()) else selectedLang= Request.queryString("language") if len(selectedLang) = 2 then session("language") = selectedLang Response.cookies("language") = selectedLang Response.Cookies("language").expires = dateAdd("d",30,now()) end if end if 'Open Database Connection call openDb() 'Store Configuration if loadConfig() = false then call errorDB(LangText("ErrConfig",""),"") end if 'Get/Set Cart/Order Session idOrder = sessionCart() 'Get/Set Customer Session idCust = sessionCust() if not IsNumeric(idCust) then idCust = session.sessionID 'Get/Set Affilate ID call getIdAffiliate(validHTML(Request.QueryString("idAff"))) 'Get action action = trim(Request.QueryString("action")) if len(action) = 0 then action = trim(Request.Form("action")) end if action = lCase(action) 'Check Product Code idProduct = trim(request("idProduct")&"") if not IsNumeric(idProduct) then 'Check SKU sku = trim(request("sku")&"") if len(sku) > 0 then mySQL = "SELECT idProduct " _ & "FROM " & tablePrefix & "products " _ & "WHERE sku = '" & validSQL(sku,"A") & "' " set rsTemp = openRSexecute(mySQL) if not rsTemp.EOF then idProduct = rsTemp("idProduct") else errMsg = LangText("ErrInvProdID","") call closeDB() Response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(errMsg) end if call closeRS(rsTemp) else errMsg = LangText("ErrInvProdID","") call closeDB() Response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(errMsg) end if end if 'Check if Product is being displayed as a Test if Instr(lCase(Request.ServerVariables("HTTP_REFERER")),"/sa_prod") = 0 then testMode = false else testMode = true end if 'Get Product Detail mySQL = "SELECT description,descriptionLong,relatedKeys,price,wholesaleprice,idUOM," _ & " listprice,smallImageUrl,imageurl,stock,sku," _ & " fileName,noShipCharge,reviewAllow,details, handlingFee, minorder " _ & "FROM " & tablePrefix & "products " _ & "WHERE idProduct = " & validSQL(idProduct,"I") & " " if not testMode then mySQL = mySQL & "AND active = -1" end if set rsTemp = openRSexecute(mySQL) if rsTemp.eof then errMsg = LangText("ErrInvProdID","") call closeDB() Response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(errMsg) end if 'Assign product DB fields to local fields relatedKeys = trim(rsTemp("relatedKeys")&"") Price = rsTemp("price") idUOM = rsTemp("idUOM") listPrice = rsTemp("listPrice") smallImageURL = trim(rsTemp("SmallImageUrl")&"") imageURL = trim(rsTemp("imageUrl")&"") Stock = rsTemp("stock") sku = trim(rsTemp("sku")&"") fileName = trim(rsTemp("fileName")&"") noShipCharge = trim(rsTemp("noShipCharge")&"") reviewAllow = trim(rsTemp("reviewAllow")&"") handlingFee = rsTemp("handlingFee") wholesaleprice = rsTemp("wholesaleprice") minorder = rsTemp("minorder") if len(minorder) = 0 or not IsNumeric(minorder) then minorder = 1 end if 'Language for product descriptions Details = trim(langProduct(idProduct,"details",rsTemp("details"))) Description = trim(langProduct(idProduct,"description",rsTemp("description"))) DescriptionLong = trim(langProduct(idProduct,"DescriptionLong",rsTemp("DescriptionLong"))) closeRS(rsTemp) 'Build a category keyword string mySQL = "SELECT a.idProduct, b.categoryDesc " _ & "FROM " & tablePrefix & "Categories_Products a INNER JOIN " & tablePrefix & "Categories b ON a.idCategory = b.idCategory " _ & "WHERE (((a.idProduct)= " & validSQL(idProduct,"I") & "));" set rsTemp = openRSexecute(mySQL) do while not rsTemp.eof cats = cats & trim(rsTemp("categoryDesc")) & "," rsTemp.moveNext loop if len(cats) > 0 then cats = mid(cats,1,len(cats) - 1) closeRS(rsTemp) 'Get the return parameters curPage = Request.Form("curPage") if len(curPage) = 0 or not IsNumeric(curPage) then curPage = 1 end if sortField = validHTML(Request.Form("sortField")) if len(sortField) = 0 then sortField = pListSortOrder end if idCategory = Request.Form("idCategory") if len(idCategory) = 0 or not IsNumeric(idCategory) then idCategory = 1 'All Categories end if %> <% 'Close Database Connection call closeDB() '************************************************************************* 'Main Shopping Cart Display Area '************************************************************************* sub cartMain() %>
<% ' Adjust for displayed currency listPrice = Exchange(listPrice) price = Exchange(price) wholesaleprice = Exchange(wholesaleprice) if Not IsNull(idCust) then userroles = session(storeID & "userroles") if (CInt(userroles) and CInt(WHOLESALER)) then if price > wholesaleprice then price = wholesaleprice end if end if 'if Request.QueryString("Msg") <> "" Then 'Response.write "
" & validHTML(Request.QueryString("Msg")) & "
" 'end if %>
<% 'Classic Layout if prodViewLayout = "0" then %>
<% call getProdDetail() %>
<% call getMisc() call getProdReview() call getFavorites() call getWishlist() %>
<% call getProdImage() call otherImages(idProduct) call getProdDisc() call getOptionsGroups() Response.write("
") call getQtyAndAdd() if lCase(SKU) <> "cert" then call getProdPricing() else call getCertPricing() end if call getMandatoryMsg() call getFreeShipMsg() %>
<% if pUseProdView = "-1" then call getProductRecommendations(idProduct) %>
<% 'Professional layout else %>
<% call getProdDetail() %>
<% if pCatalogOnly = 0 then %>

<%=LangText("GenReadyToOrder","")%>

<% end if call getProdDisc() call getOptionsGroups() call getMandatoryMsg() call getQtyAndAdd() call getProdPricing() call getProdStock(idProduct) call getFreeShipMsg() call getProdReview() call getMisc() call getFavorites() call getWishlist() %>
<% call getProdImage() call otherImages(idProduct) %>
<% if pUseProdView = "-1" then call getProductRecommendations(idProduct) end if %>
 
<% end if %> <% end sub '************************************************************************* ' Display Product Details '************************************************************************* sub getProdDetail() %>

<%=Description%>

<% if len(Details) = 0 then %> <%call getProdStock(idProduct)%><%=DescriptionLong%> <% else %> <%call getProdStock(idProduct)%><%=Details%> <% end if %>
<% end sub '************************************************************************* ' Display Product Pricing '************************************************************************* sub getProdPricing() 'Check if we need to hide pricing if price=0 if pHidePricingZero=-1 and Price=0 then exit sub end if 'Show Prices %>
<% if lCase(sku) = "cert" then 'do nothing Else if listPrice > Price then %> <%=LangText("GenListPrice","")%> : <%=moneyS(ListPrice)%>
<% end if %> <%=LangText("GenOurPrice","")%> : <%=moneyS(Price)%> <% if (listPrice - Price) > 0 then %>
<%=LangText("GenYouSave","")%> : <%=moneyS(ListPrice-Price)%> (<%=formatNumber((((listPrice-Price)/listPrice)*100),0)%>%) <% end if if handlingFee > 0 then %>

+ <%=LangText("GenHandlingFee","")%> : <%=moneyS(Exchange(handlingFee))%> <% end if end if %>
<% end sub '************************************************************************* ' Display Certificate Pricing '************************************************************************* sub getCertPricing() 'Place a page break here to adjust the spacing as we don't need to 'show the products price. response.write "
" end sub '************************************************************************* ' Display Product Stock Description '************************************************************************* sub getProdStock(idProduct) dim rsTemp, mySQL mySQL = "SELECT stock FROM " & tablePrefix & "products WHERE idproduct = " & validSQL(idProduct,"I") set rsTemp = openRSexecute(mySQL) if not rsTemp.eof then if pShowStockView = -1 then response.write "( " if pHideAddStockLevel = -1 then %> <%=LangText("GenInStock","")%> <% else if rsTemp("stock") > pHideAddStockLevel then %> <%=LangText("GenInStock","")%> <% else %> <%=LangText("GenOutStock","")%> <% end if end if response.write " )" end if end if end sub '************************************************************************* ' Display Free Shipping message '************************************************************************* sub getFreeShipMsg() if UCase(noShipCharge) = "Y" and len(fileName) = 0 then %>

<%=LangText("GenFreeShipping","")%>
<% end if end sub '************************************************************************* ' Produce a selection box for the price of the gift certificate '************************************************************************* sub certAmount() dim mySQL, rsTemp, i %>
<% end sub '************************************************************************* ' Display Product Options '************************************************************************* sub getOptionsGroups() dim mySQL, rstemp, rstemp2, rstemp3, optionDesc if lCase(sku) = "cert" then call certAmount end if 'Initialise mandatory option counter numMandatoryOpt = 0 'Get option groups for this Product mySQL = "SELECT a.idOptionGroup, a.optionGroupDesc, " _ & " a.optionReq, a.optionType, a.optionLength " _ & "FROM " & tablePrefix & "optionsGroups a, " & tablePrefix & "optionsGroupsXref b " _ & "WHERE a.idOptionGroup = b.idOptionGroup " _ & "AND b.idProduct = " & validSQL(idProduct,"I") & " " _ & "ORDER BY a.sortOrder, a.optionGroupDesc " set rsTemp2 = openRSexecute(mySQL) 'Extra line break before displaying option groups if not rsTemp2.EOF then Response.Write "
" end if 'Loop through option groups do while not rstemp2.EOF 'Get Options for Option Group mySQL = "SELECT b.idOption, b.optionDescrip, b.priceToAdd, " _ & " b.percToAdd " _ & "FROM " & tablePrefix & "optionsXref a, " & tablePrefix & "options b " _ & "WHERE a.idOptionGroup = " & rstemp2("idOptionGroup") & " " _ & "AND b.idOption = a.idOption " _ & "AND NOT EXISTS " _ & " (SELECT c.idOptionsProdEx " _ & " FROM " & tablePrefix & "OptionsProdEx c " _ & " WHERE c.idOption = b.idOption " _ & " AND c.idProduct = " & validSQL(idProduct,"I") & ") " _ & "ORDER BY b.sortOrder, b.optionDescrip " set rsTemp3 = openRSexecute(mySQL) if not rstemp3.EOF then 'Show option headings if UCase(rstemp2("optionReq")) = "Y" then numMandatoryOpt = numMandatoryOpt + 1%> <%=LangText(rstemp2("optionGroupDesc"),rstemp2("optionGroupDesc"))%> <%=LangText("GenRequired","(Required)")%> :
<% else %> <%=LangText(rstemp2("optionGroupDesc"),rstemp2("optionGroupDesc"))%> :
<% end if 'Create hidden variables that will be used in validations %> <% 'Show Drop-Down List options if rstemp2("optionType") = "S" then if UCase(rstemp2("optionReq")) = "Y" and OptionInventory(idProduct) then %> <% end if %> <% do while not rstemp3.EOF priceToAdd = Exchange(getOptionPrice(rstemp3("priceToAdd"),rstemp3("percToAdd"),price)) optionDesc = LangText(rstemp3("optionDescrip"),rstemp3("optionDescrip")) if priceToAdd > 0 then optionDesc = optionDesc & " " end if %> <% rstemp3.movenext loop %>
<% end if 'Show Radio Button options if rstemp2("optionType") = "R" then 'Only show "Not Applicable" if the option group is optional if UCase(rstemp2("optionReq")) = "N" then %>    <%=LangText("GenNotApplicable","")%>
<% end if do while not rstemp3.EOF priceToAdd = Exchange(getOptionPrice(rstemp3("priceToAdd"),rstemp3("percToAdd"),price)) optionDesc = rstemp3("optionDescrip") if priceToAdd > 0 then optionDesc = optionDesc & " " end if if OptionInventory(idProduct) then %>    <% else %>    <% end if %> <%=optionDesc%> (<%=moneyS(priceToAdd)%>)
<% rstemp3.movenext loop %>
<% end if 'Show Checkbox options if rstemp2("optionType") = "C" then do while not rstemp3.EOF priceToAdd = Exchange(getOptionPrice(rstemp3("priceToAdd"),rstemp3("percToAdd"),price)) optionDesc = rstemp3("optionDescrip") if priceToAdd > 0 then optionDesc = optionDesc & " " end if if OptionInventory(idProduct) then %>    <% else %>    <% end if %> <%=optionDesc%> (<%=moneyS(priceToAdd)%>)
<% rstemp3.movenext loop %>
<% end if 'Show Text Input options if rstemp2("optionType") = "T" then if rsTemp2("optionLength") > 25 then optSize = 25 else optSize = rsTemp2("optionLength") end if %> <% if rstemp2("idOptionGroup") = 5 then %>
<% else %> " name='TXTidOption<%=rstemp2("idOptionGroup")%>' size="<%=optSize%>" maxlength='<%=rsTemp2("optionLength")%>' class="CPoptTxt" />
<% end if %> <% end if end if call closeRS(rsTemp3) rstemp2.movenext loop call closeRS(rsTemp2) if numMandatoryOpt > 0 and OptionInventory(idProduct) then %>
<%=LangText("GenSelectOptions","Select options to view item stock.")%>
<%=LangText("ItemsInStock","Number available: ")%>0
<% end if end sub '************************************************************************* ' Display Qty box and Add Button '************************************************************************* sub getQtyAndAdd() if pCatalogOnly = 0 and _ (pHideAddStockLevel = -1 or _ pHideAddStockLevel < CDbl(Stock)) then %>
  <% if minorder > 1 then response.write "

"& LangText("MinQuantityOrder","Product requires a minimum order of ") & minorder &"

" %>
<% end if end sub '************************************************************************* ' Display Product Discounts '************************************************************************* sub getProdDisc() dim mySQL, rstemp 'Get Product Discounts mySQL="SELECT discAmt,discFromQty,discToQty,discPerc " _ & "FROM " & tablePrefix & "DiscProd " _ & "WHERE idProduct = " & validSQL(idProduct,"I") & " " _ & "ORDER BY discFromQty" set rsTemp = openRSexecute(mySQL) if not rsTemp.EOF then %>

<%=LangText("GenDiscount","")%> (<%=LangText("GenQty","")%>) :

<% do while not rsTemp.EOF %> <% rsTemp.Movenext loop %>
<%=rsTemp("discFromQty")%>  -  <% if rsTemp("discToQty") > 9999 then Response.Write ">" else Response.Write rsTemp("discToQty") end if %>     <%=LangText("GenSave","")%>  <% if isNull(rsTemp("discPerc")) then %> <%=moneyS(Exchange(rsTemp("discAmt")))%> <% Response.write " " & LangText("GenEach","") else Response.Write rsTemp("discPerc") & "% " & LangText("GenEach","") end if %>
<% end if call closeRS(rsTemp) end sub '************************************************************************* ' Display Related Products '************************************************************************* sub getProdRelated() dim mySQL, rstemp, rsTemp2 dim count dim price const bullet = "
  • " %>
    <% 'Get categories for this product mySQL="SELECT a.idCategory, b.categoryDesc " _ & "FROM " & tablePrefix & "Categories_Products a " _ & "INNER JOIN " & tablePrefix & "Categories b " _ & "ON a.idCategory = b.idCategory " _ & "WHERE a.idProduct = " & validSQL(idProduct,"I") set rsTemp = openRSexecute(mySQL) do while not rsTemp.eof %> <% rsTemp.movenext loop call closeRS(rsTemp) 'Related keys for this product if len(relatedKeys) > 0 then %> <% end if %>
    <% end sub '************************************************************************* ' Display Product Review Summary '************************************************************************* sub getProdReview() dim mySQL, rstemp 'Check if reviews are allowed for this product if UCase(reviewAllow) = "Y" then %>

    <%=LangText("GenProductReviews","")%> :

    <% 'Get current ratings mySQL="SELECT SUM(revRating) AS revSum, " _ & " COUNT(revRating) AS revCount " _ & "FROM " & tablePrefix & "reviews " _ & "WHERE idProduct = " & validSQL(idProduct,"I") & " " _ & "AND revStatus = 'A' " set rsTemp = openRSexecute(mySQL) if not rsTemp.EOF then revSum = rsTemp("revSum") revCount = rsTemp("revCount") else revSum = 0 revCount = 0 end if call closeRS(rsTemp) 'Show Ratings if revSum > 0 and revCount > 0 then %> <%=LangText("GenAverageRating","")%> : <%=ratingImage(revSum/revCount)%>
    <%=LangText("GenNumberReviews","")%> : <%=revCount%>
    <% end if %> <%=LangText("GenWriteReview","")%>
    <% end if end sub '************************************************************************* ' Display Product Image '************************************************************************* sub getProdImage() if imageURL <> "" then %> <%=server.HTMLEncode(description)%> <% else if smallImageURL <> "" then %> <%=server.HTMLEncode(description)%> <% else %> <%=LangText("GenNoImage","")%> <% end if end if end sub '************************************************************************* ' Get other images '************************************************************************* sub otherimages(idProduct) dim mySQL dim rs %> <% mySQL = "SELECT smallimageurl, imageurl, title, sort " _ & "FROM " & tablePrefix & "prodImages " _ & "WHERE idProduct = " & idProduct & " " _ & "ORDER BY [sort] " set rs = openRSexecute(mySQL) if not rs.eof then %> <% end if do while NOT rs.eof %> " alt="<%=rs("title")%>" border="0" />  <% rs.movenext loop %>
    <% end sub '************************************************************************* ' Display Miscellaneous items '************************************************************************* sub getMisc() if mailComp <> 0 or demoMode = "Y" then if pEmailFriend = "-1" or pProdInquiry = "-1" then %>

    <%=LangText("GenMiscellaneous","")%> :

    <% if pEmailFriend = "-1" then %> <%=LangText("GenEmailFriendHdr","")%>
    <% end if if pProdInquiry = "-1" then %> <%=LangText("GenProdInquiry","")%>
    <% end if end if end if end sub '************************************************************************* ' Display "Favorites" '************************************************************************* sub getFavorites if FavoritesEnabled = "-1" then %> <%=LangText("GenAddFav","Add to Favorites")%>
    <% end if end sub '************************************************************************* ' Display "Wish List" '************************************************************************* sub getWishList if WishlistEnabled = "-1" then %> <%=LangText("GenAddWishlist","Add to Wish List")%> <% end if end sub '************************************************************************* ' Display "Mandatory" message '************************************************************************* sub getMandatoryMsg() if numMandatoryOpt > 0 then %> <% end if end sub '******************************************************************************* ' Display product recommendations based upon a given product '******************************************************************************* sub getProductRecommendations(idProduct) dim smallImageURL ' response.write "getProductRecommendations(" & idProduct & ")
    " mySQL = "SELECT " & tablePrefix & "products.idProduct, sku, description, descriptionLong, imageURL, smallImageURL, idCategory " _ & "FROM " & tablePrefix & "categories_products INNER JOIN " & tablePrefix & "products ON " & tablePrefix & "categories_products.idProduct = " & tablePrefix & "products.idProduct " _ & "WHERE active = -1 AND " & tablePrefix & "products.idProduct IN " _ & "(SELECT TOP " & prodViewRecommendationsCount & " idProduct FROM " & tablePrefix & "cartrows WHERE idOrder IN " _ & " (SELECT idOrder FROM " & tablePrefix & "cartrows WHERE idProduct = " & idproduct & ") " _ & "AND idProduct <> " & idProduct & " " _ & "GROUP BY idProduct " _ & "ORDER BY COUNT(idProduct) DESC )" 'response.write mySQL & "
    " set rsTemp = openRSexecute(mySQL) if not rsTemp.eof then %>

    <%=LangText("genRecommendProducts","People that purchase this product also purchased : ") %>

    <% do while not rsTemp.eof ' Display the recommended products smallImageURL = rsTemp("smallImageURL") imageURL = rsTemp("imageURL") if len(smallImageURL) = 0 then if len(imageURL) <> 0 then smallImageURL = imageURL end if end if if len(smallImageURL) > 0 then %>
    " <%=ImageResize(server.mappath(pImagesDir & smallImageURL),pWThumb,pHThumb,"thumb")%> />

    <%=rsTemp("description") %>

    <%=rsTemp("DescriptionLong") %>
    <% end if rsTemp.movenext loop %>
    <% end if end sub function OptionInventory(idProduct) dim mySQL, rsTemp OptionInventory = false mySQL = "SELECT inventory FROM " & tablePrefix & "optionsInventory WHERE idproduct = " & validSQL(idProduct,"I") & ";" 'response.write mySQL set rsTemp = openRSexecute(mySQL) if not rsTemp.eof then OptionInventory = true end if closeRS(rsTemp) end function %>