<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "18, 33, 55, 104, 105, 108, 150, 151, 152, 156, 157, 158, 159, 160, 161, 265, 266, 294, 295, 296, 648, 779, 1182, 1183, 1184, 1236, 1237, 1311, 1312, 1313, 1336, 1337, 1338, 1339, 1340, 1398, 1442, 1443, 1477, 1617, 1618, 1619, 1620, 1621, 1623, 1659, 1673, 1703, 1704, 1705, 1781, 1782, 1788, 1789, 1791, 1792, 1806, 1807, 1882, 1907, 1908, 1909, 1910, 1911" blnDateStrings = true %> <% '=============================================== ' CactuShop ASP Shopping Cart ' ©1999-2007 Cactusoft International FZ-LLC ' www.cactusoft.com '=============================================== ' All rights reserved. ' Use of this code is covered by the terms and ' conditions in the license agreement. No ' unauthorized duplication or distribution is ' permitted. Cactusoft's copyright notices must ' remain in the ASP sections of the code. '=============================================== '----------------------------------------------- 'COLLECT VALUES FROM FORM '----------------------------------------------- 'May be from 404 data Set objDynamicLinks = New DynamicLinks Call objDynamicLinks.Build(request.QueryString, objRecordSet) If objDynamicLinks.PageType = "product" then V_ID = 0 P_ID = objDynamicLinks.ProdID CAT_ID = objDynamicLinks.CatID strSelectedOptions = "" else V_ID = NumSafe(request.Querystring("V_ID")) P_ID = NumSafe(request.Querystring("P_ID")) CAT_ID = NumSafe(request.Querystring("CAT_ID")) strSelectedOptions = Request.QueryString("strOptions") end if 'Useful application variables strAppUploadsFolder = GetAppVar("uploadsfolder") '----------------------------------------------- 'SECURITY CHECKS '----------------------------------------------- 'If this gets set, don't show the product. This is 'security for language-specific products blnNoShow = false 'If using access, append products table name for casting if strDatabaseType = "access" then strTblProd = "tblCactuShop" & TABLE_PREFIX & "Products." else strTblProd = "" '----------------------------------------------- 'FORMAT QUERY AND RUN IT '----------------------------------------------- strQuery2 = "SELECT CAT_Live, CAT_Name" & CInt(numLanguageID) & ", P_StrapLine" & CInt(numLanguageID) & ", P_Live, P_Name" & CInt(numLanguageID) & ", P_SpecTable" & CInt(numLanguageID) & ", " & strTblProd & castSQL("P_Desc" & CInt(numLanguageID)) & " as P_Desc" & CInt(numLanguageID) & ", P_HyperLink" & CInt(numLanguageID) & ", P_OrderVersionsBy, P_VersionDisplayType, P_Reviews FROM ((((tblCactuShop" & TABLE_PREFIX & "Versions INNER JOIN tblCactuShop" & TABLE_PREFIX & "TaxRates ON tblCactuShop" & TABLE_PREFIX & "Versions.V_Tax = tblCactuShop" & TABLE_PREFIX & "TaxRates.T_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products ON tblCactuShop" & TABLE_PREFIX & "Versions.V_ProductID = tblCactuShop" & TABLE_PREFIX & "Products.P_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink ON tblCactuShop" & TABLE_PREFIX & "Products.P_ID = tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_ProductID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Categories ON tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_CategoryID = tblCactuShop" & TABLE_PREFIX & "Categories.CAT_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON tblCactuShop" & TABLE_PREFIX & "Products.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE P_ID=" & P_ID & " AND V_Live='y' AND P_Live='y' AND V_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_Live='y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND (SUP_Live <> 'n' OR SUP_Live IS NULL)" Call ExecuteRS(strQuery2, objRecordSet) If not (objRecordSet.BOF And objRecordSet.EOF) then P_OrderVersionsBy = objRecordSet("P_OrderVersionsBy") P_VersionDisplayType = objRecordSet("P_VersionDisplayType") P_Reviews = objRecordSet("P_Reviews") P_Name = objRecordSet("P_Name" & numLanguageID) CAT_Name = objRecordSet("CAT_Name" & numLanguageID) blnNoShow = (P_Name & "" = "") 'Set the string to use as the title of this page - good for search engines! 'Note that description now may be altered below in the custom product attributes strPageTitleHTML = P_Name & GetString("PageTitle_Separator") & GetString("Config_Webshopname") strMetaDescHTML = left(objRecordSet("P_Desc" & CInt(numLanguageID)), 300) 'Save this to recently viewed products If GetAppVar("recentproducts") > 0 then Call SaveToRecentProducts(P_ID) End If else blnNoShow = true end if '----------------------------------------------- 'PRODUCT TRACKING '----------------------------------------------- if GetAppVar("tracking") = "y" and blnLoggedInToBackend = false then strQuery = "INSERT INTO tblCactuShop" & TABLE_PREFIX & "ProductStats (PS_ProductID, PS_Date, PS_IP) VALUES (" & _ P_ID &_ "," & strDateDelimiter & ReverseDate(NowOffset()) & strDateDelimiter &_ ",'" & SQLSafe(Request.ServerVariables("HTTP_HOST")) & "')" Call ExecuteNonQuery(strQuery) End if If not (objRecordSet.BOF And objRecordSet.EOF) and not blnNoShow then '----------------------------------------------- 'GET LOCATION BAR 'We've moved this up so that we can check that 'all categories below us are 'legal' for 'this language. If not, we should show 'the unavailable sign '----------------------------------------------- Set objTrail = New BreadCrumbTrail If objDynamicLinks.PageType = "product" then objTrail.Parents = objDynamicLinks.CatParents objTrail.PageHistory = objDynamicLinks.PageHistory End If 'Get keyword search array if we've come from the search If objTrail.PageHistory = "search" then aryKeywords = CreateKeywordArray(objCactuSession.Value("search_keywords"), objCactuSession.Value("search_searchcriteria")) End If 'Get out the category name If CAT_ID = 0 then CAT_Name = "" Else strQuery = "SELECT CAT_Name" & numLanguageID & " FROM tblCactuShop" & TABLE_PREFIX & "Categories WHERE CAT_ID=" & NumSafe(CAT_ID) & " AND CAT_Live = 'y'" Call ExecuteRS(strQuery, objRecordSet2) If not (objRecordSet2.BOF and objRecordSet2.EOF) then CAT_Name = objRecordSet2(0) End If objRecordSet2.Close End If 'Build the trail Call objTrail.Build(objRecordSet2, CAT_ID, CAT_Name, P_Name) 'Build the attributes If SOFTWARE_IS_PRO then Set objAttributes = New ProductAttributes Call objAttributes.Build(P_ID) 'Set the meta data if required If objAttributes.MetaDescriptionHTML <> "" then strMetaDescHTML = objAttributes.MetaDescriptionHTML If objAttributes.MetaKeywordsHTML <> "" then strMetaKeywordsHTML = objAttributes.MetaKeywordsHTML If objAttributes.MetaPageTitleHTML <> "" then strPageTitleHTML = objAttributes.MetaPageTitleHTML End If end if '// got a product? '----------------------------------------------- 'Buildpage comes down here because settings like 'meta tags are dependant on the code above '----------------------------------------------- %><% '----------------------------------------------- 'READ PAGE TEMPLATE FROM FILE '----------------------------------------------- Call ReadFromTemplate(strTemplateLocation, aryPageTemplate) '----------------------------------------------- 'WRITE FIRST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(0)) If blnNoShow then 'Product doesn't exist - show message %>

<% WriteString("ContentText_ProductUnavailable") %>

<% else %>

<%= P_Name %>

<%= objTrail.ToHTML %>
<% 'Strapline If objRecordSet("P_StrapLine" & CInt(numLanguageID))<>"" then response.Write "" & objRecordSet("P_StrapLine" & CInt(numLanguageID)) & "" & vbcrlf end if 'Product Image - set up useful stuff Dim objFileSystem, aryFileTypes, strProductPath, strProductLargePath Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject") aryFileTypes = Split(GetAppVar("allowedimages"), ",") strProductPath = Server.MapPath(strAppUploadsFolder & "images_products/") strProductLargePath = Server.MapPath(strAppUploadsFolder & "images_products_large/") 'Blank out values strThumbnail = "" strLargeImagePopupHTML = "" 'Find the thumbnail and main images strThumbnailName = GetFileLocation(strProductPath, P_ID, aryFileTypes, objFileSystem) strMainImageName = GetFileLocation(strProductLargePath, P_ID, aryFileTypes, objFileSystem) 'Set small image HTML If strThumbnailName <> "" Then strThumbnailHTML = "" End If 'Find and show large image - and look up the file size for popup definition If strMainImageName <> "" Then If gfxSpex(strProductLargePath & "\" & strMainImageName, numImageWidth, numImageHeight, numColDepth, strType) = True Then 'We have a large image - add popup link to thumbnail and create normal anchor link strImage = strMainImageName strImageType = "product" strLargeImageLinkHTML = "" strThumbnailHTML = strLargeImageLinkHTML & strThumbnailHTML & "" strLargeImagePopupHTML = "
" & strLargeImageLinkHTML & GetString("ContentText_LargeView") & "
" End if End If 'Write out the thumnail image response.write strThumbnailHTML & vbcrlf 'Product description P_Desc = objRecordSet("P_Desc" & CInt(numLanguageID)) If GetAppVar("convertdescbreaks") = "y" then P_Desc = replace(P_Desc, vbcrlf, "
") end if If V_ID = 0 then P_Desc = Highlight(P_Desc, aryKeywords) end if If P_Desc & "" <> "" then response.Write "

" & P_Desc & "

" & vbcrlf End If %>
<% '-------------------------------------------------- ' CUSTOM ATTRIBUTES TABLE ' Display the attributes from the array '-------------------------------------------------- If SOFTWARE_IS_PRO Then Call objAttributes.WriteHTML(aryKeywords) End If 'Spec table P_SpecTable = objRecordSet("P_SpecTable" & CInt(numLanguageID)) & "" If P_SpecTable <> "" then %>
<%= P_SpecTable %>
<% end if '-------------------------------------------------- ' VERSION DISPLAY '-------------------------------------------------- objRecordSet.close numBgCount = 0 '----------------------------------------------- 'GENERATE TABLE OF VERSIONS OR OPTION GROUPS '----------------------------------------------- strVersionsOrderBy = GetAppVar("sortversions") If P_OrderVersionsBy <> "" then strVersionsOrderBy = P_OrderVersionsBy If strVersionsOrderBy = "" then strVersionsOrderBy = "V_Name" if strVersionsOrderBy = "V_Name" or strVersionsOrderBy = "V_Desc" then strVersionsOrderBy = strVersionsOrderBy & CInt(numLanguageID) If P_VersionDisplayType = "g" or P_VersionDisplayType = "l" then 'Doing an option group. We don't need to pull out the versions - just the option groups strQuery = "SELECT OPTG_ID, OPTG_Name" & CInt(numLanguageID) & ", OPTG_Desc" & CInt(numLanguageID) & ", OPTG_OptionDisplayType FROM tblCactuShop" & TABLE_PREFIX & "OptionGroups INNER JOIN tblCactuShop" & TABLE_PREFIX & "ProductOptionGroupLink ON tblCactuShop" & TABLE_PREFIX & "OptionGroups.OPTG_ID = tblCactuShop" & TABLE_PREFIX & "ProductOptionGroupLink.P_OPTG_OptionGroupID WHERE tblCactuShop" & TABLE_PREFIX & "ProductOptionGroupLink.P_OPTG_ProductID = " & P_ID & " ORDER BY P_OPTG_OrderByValue" Else 'If using access, append versions table name for casting if strDatabaseType = "access" then strTblVer = "v." else strTblVer = "" strQuery = "SELECT DISTINCT T_Taxrate, V_ID, V_Price, V_Weight, V_RRP, V_Tax, V_ProductID, V_CodeNumber, V_Quantity, V_Quantity, V_QuantityWarnLevel, " & strVersionsOrderBy & " As OrderByBit, V_Name" & numLanguageID & ", " & strTblVer & castSQL("V_Desc" & numLanguageID) & " as V_Desc" & numLanguageID & ", MIN(QD_ID) As QuantityDiscount FROM (tblCactuShop" & TABLE_PREFIX & "Versions v INNER JOIN tblCactuShop" & TABLE_PREFIX & "TaxRates tr ON v.V_Tax = tr.T_ID) LEFT JOIN tblCactuShop" & TABLE_PREFIX & "QuantityDiscounts qd ON v.V_ID = qd.QD_VersionID WHERE V_Live = 'y' AND V_CustomerGroupID IN (0," & numSafe(DB_CG_ID) & ") AND V_ProductID=" & P_ID & " AND V_Name" & numLanguageID & " <> '' GROUP BY T_Taxrate, V_ID, V_Price, V_Weight, V_RRP, V_Tax, V_ProductID, V_CodeNumber, V_Quantity, V_QuantityWarnLevel, " & strVersionsOrderBy & ", V_Name" & numLanguageID & ", " & castSQL("V_Desc" & numLanguageID) & " ORDER BY " & strVersionsOrderBy End If Call ExecuteRS(strQuery, objRecordSet) blnGotMoreThanOneVersion = (objRecordSet.RecordCount > 1) '----------------------------------------- 'CUSTOMER GROUP PRICING '----------------------------------------- If DB_CG_ID > 0 then strQuery = GetCustomerGroupPricesQuery(P_ID, strVersionsOrderBy) Call ExecuteRS(strQuery, objRecordSet2) End If 'Show the versions Set objRecordSetOptions = Server.CreateObject("ADODB.RecordSet") Call ShowVersions(objRecordSet, objRecordSet2, objRecordSetOptions, P_ID, P_VersionDisplayType, "product", objFileSystem, aryKeywords, 1, objTrail, strSelectedOptions) Set objRecordSetOptions = Nothing If DB_CG_ID > 0 then objRecordSet2.Close objRecordSet.Close %> <% '----------------------------------------- 'PRODUCT PROMOTIONS 'Display the related product promos '----------------------------------------- If SOFTWARE_IS_PRO then Call DisplayPromotionsForProduct(P_ID) End if '----------------------------------------- 'PRODUCT REVIEWS 'Display the product reviews, and a link 'to add a review. '----------------------------------------- If GetAppVar("enablereviews") = "y" and P_Reviews <> "n" then strAppReviewPermission = GetAppVar("reviewpermission") If strAppReviewPermission = "customersonly" then blnGotReviewPermission = (DB_C_ID > 0) ElseIf strAppReviewPermission = "purchasersonly" then strQuery = "SELECT null FROM (tblCactuShop" & TABLE_PREFIX & "Versions INNER JOIN tblCactuShop" & TABLE_PREFIX & "InvoiceRows ON tblCactuShop" & TABLE_PREFIX & "Versions.V_CodeNumber = tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_VersionCode) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Orders ON tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_OrderNumberID = tblCactuShop" & TABLE_PREFIX & "Orders.O_ID WHERE O_CustomerID = " & DB_C_ID & " AND O_Sent = 'y' AND O_Shipped = 'y' AND V_ProductID=" & P_ID Call ExecuteRS(strQuery, objRecordSet) blnGotReviewPermission = Not (objREcordSet.BOF and objREcordSet.EOF) objRecordSet.Close Else blnGotReviewPermission = true end if 'Start the review table %>

<% WriteString("ContentText_CustomerReviews") %>

<% 'Get review config setting that will be used on the display strAppRatingOnReviews = GetAppVar("ratingonreviews") strAppTitleOnReviews = GetAppVar("titleonreviews") strAppReviewDateFormat = GetAppVar("reviewdateformat") numReviewRatingMax = GetAppVar("reviewratingmax") numReviewLimit = GetAppVar("reviewlimit") 'Pull out all reviews for this product that are live and 'in this language strQuery = LimitSQL("tblCactuShop" & TABLE_PREFIX & "Reviews.*, tblCactuShop" & TABLE_PREFIX & "Versions.V_Name" & numLanguageID & " FROM tblCactuShop" & TABLE_PREFIX & "Reviews LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Versions ON tblCactuShop" & TABLE_PREFIX & "Reviews.REV_VersionID = tblCactuShop" & TABLE_PREFIX & "Versions.V_ID WHERE REV_ProductID = " & P_ID & " AND REV_Live = 'y' AND REV_LanguageID = " & CInt(numLanguageID) & " ORDER BY REV_DateCreated DESC", IIf(numReviewLimit = 0, -1, numReviewLimit), false) Call ExecuteRS(strQuery, objRecordSet) If not (objREcordSet.BOF and objREcordSet.EOF) then blnNoReviews = false 'Loop through all reviews Do While not objRecordSet.EOF REV_Title = WriteSafe(objRecordSet("REV_Title")) REV_Text = Replace(WriteSafe(objRecordSet("REV_Text")), vbcrlf, "
") REV_Rating = WriteSafe(objRecordSet("REV_Rating")) REV_Name = WriteSafe(objRecordSet("REV_Name")) REV_Location = WriteSafe(objRecordSet("REV_Location")) REV_Email = WriteSafe(objRecordSet("REV_Email")) REV_DateCreated = objRecordSet("REV_DateCreated") REV_DateLastUpdated = objRecordSet("REV_DateLastUpdated") V_Name = objRecordSet("V_Name" & CInt(numLanguageID)) %>
<% 'Rating strReviewStarsHTML = "" If strAppRatingOnReviews <> "no" and REV_Rating > 0 then For i = 1 to numReviewRatingMax If REV_Rating >= i then strRatingImage = "reviewyes.gif" strRatingImageAlt = "*" Else strRatingImage = "reviewno.gif" strRatingImageAlt = "-" End If strReviewStarsHTML = strReviewStarsHTML & "" Next response.Write "
" & strReviewStarsHTML & "
" & vbcrlf End If 'Title If strAppTitleOnReviews <> "no" and REV_Title <> "" then response.Write "" & REV_Title & "" & vbcrlf end if 'Name and location strReviewerHTML = GetString("ContentText_ReviewedBy") If REV_Name <> "" then strReviewerHTML = strReviewerHTML & REV_Name else strReviewerHTML = strReviewerHTML & GetString("ContentText_ReviewedByAnon") End If If REV_Location <> "" then strReviewerHTML = strReviewerHTML & GetString("ContentText_ReviewedByFrom") & REV_Location End If 'Review out various fields response.Write "
" & strReviewerHTML & "
" & vbcrlf response.Write "

" & REV_Text & "

" & vbcrlf response.Write "
" & FormatDate(REV_DateCreated, strAppReviewDateFormat) & "
" & vbcrlf 'Show the 'applies to' text if this record is linked to 'a version, if it's allowed on this product, and if there's more 'than one version being displayed If V_Name & "" <> "" and P_Reviews <> "v" and blnGotMoreThanOneVersion then response.Write "
" & GetString("ContentText_ReviewAppliesTo1") & V_Name & GetString("ContentText_ReviewAppliesTo2") & "
" & vbcrlf End If %>
<% 'Move on to the next record objRecordSet.MoveNext Loop Else blnNoReviews = true %>

<% WriteString("ContentText_NoReviews") %>

<% End If objRecordSet.Close 'Add a link to add a new review. Different lang string depending on 'whether there are any existing reviews. If blnGotReviewPermission then %> <% end if %>
<% end if '----------------------------------------- '----------------------------------------- 'CROSS SELLING STUFF 'Related products, people who bought this 'also bought, related categories. '----------------------------------------- 'Build up the title bit. Because it's possible 'that no cross-selling bits will be shown, we 'only want to write out the title when the first 'bit occurs strCarryOnShopping = "
" & vbcrlf strCarryOnShopping = strCarryOnShopping & "

" & GetString("ContentText_CarryOnShopping") & "

" & vbcrlf 'Build up a list of products already done, so they 'aren't repeated in the lists lower down. Comma- 'seperate any products here if you don't want them 'ever showing in a list strProductsDone = "0" '----------------------------------------- 'DO RELATED PRODUCTS (IF ANY) '----------------------------------------- strQuery = "SELECT P_ID, P_Name" & CInt(numLanguageID) & " FROM (tblCactuShop" & TABLE_PREFIX & "RelatedProducts INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products ON tblCactuShop" & TABLE_PREFIX & "RelatedProducts.RP_ChildID = tblCactuShop" & TABLE_PREFIX & "Products.P_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON tblCactuShop" & TABLE_PREFIX & "Products.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE RP_ParentID = " & P_ID & " AND P_Live = 'y' AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND (SUP_Live <> 'n' OR SUP_Live IS NULL) AND P_ID NOT IN (" & strProductsDone & ") ORDER BY P_Name" & CInt(numLanguageID) Call ExecuteRS(strQuery, objRecordSet) If not (objRecordSet.BOF and objRecordSet.EOF) Then 'Write out the title If not blnDoneCrossSelling then response.Write strCarryOnShopping blnDoneCrossSelling = True End If %>

<% WriteString("ContentText_RelatedProducts") %>:

<% End If 'End Related Products objRecordSet.Close '----------------------------------------- 'RECENTLY VIEWED PRODUCTS 'Get recent products, excluding the one that 'we're on at the moment. We can trust this 'string as safe (checking handling in the 'Function. '----------------------------------------- numAppRecentProducts = GetAppVar("recentproducts") If numAppRecentProducts > 0 then strRecentProducts = GetRecentProducts(numAppRecentProducts, P_ID) If strRecentProducts = "" then strRecentProducts = "0" strQuery = "SELECT P_ID, P_Name" & CInt(numLanguageID) & " FROM tblCactuShop" & TABLE_PREFIX & "Products LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON tblCactuShop" & TABLE_PREFIX & "Products.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE P_Live = 'y' AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND (SUP_Live <> 'n' OR SUP_Live IS NULL) AND P_ID IN (" & strRecentProducts & ") AND P_ID NOT IN (" & strProductsDone & ") AND P_Name" & numLanguageID & " <> '' ORDER BY P_Name" & CInt(numLanguageID) Call ExecuteRS(strQuery, objRecordSet) If not (objRecordSet.BOF and objRecordSet.EOF) Then 'Write out the title If not blnDoneCrossSelling then response.Write strCarryOnShopping blnDoneCrossSelling = True End If %>

<% WriteString("ContentText_RecentlyViewedProducts") %>

<% End If objRecordSet.Close End If '----------------------------------------- 'DO 'PEOPLE WHO BOUGHT...' 'but don't include anything that was 'listed in the related products bit '----------------------------------------- numPeopleWhoBought = GetAppVar("peoplewhobought") If numPeopleWhoBought > 0 and GetAppVar("catalogueonly") <> "y" then if GetAppVar("peoplewhoboughtjustorder") = "n" then 'This one groups across multiple orders for a customer. I.e. if a customer purchases 1 item, 'them comes back later and purchases another item, the two are linked together. strQuery = "AlsoProducts.P_ID, AlsoProducts.P_Name" & numLanguageID & ", COUNT(*) As TotalMatches FROM ((tblCactuShop" & TABLE_PREFIX & "InvoiceRows AS AlsoInvoiceRows INNER JOIN (tblCactuShop" & TABLE_PREFIX & "Versions AS AlsoVersions INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products AS AlsoProducts ON AlsoVersions.V_ProductID = AlsoProducts.P_ID) ON AlsoInvoiceRows.IR_VersionCode = AlsoVersions.V_CodeNumber) INNER JOIN (tblCactuShop" & TABLE_PREFIX & "Orders AS AlsoOrderNumbers INNER JOIN (((tblCactuShop" & TABLE_PREFIX & "Versions INNER JOIN tblCactuShop" & TABLE_PREFIX & "InvoiceRows ON tblCactuShop" & TABLE_PREFIX & "Versions.V_CodeNumber = tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_VersionCode) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Orders ON tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_OrderNumberID = tblCactuShop" & TABLE_PREFIX & "Orders.O_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Customers ON tblCactuShop" & TABLE_PREFIX & "Orders.O_CustomerID = tblCactuShop" & TABLE_PREFIX & "Customers.C_ID) ON AlsoOrderNumbers.O_CustomerID = tblCactuShop" & TABLE_PREFIX & "Customers.C_ID) ON AlsoInvoiceRows.IR_OrderNumberID = AlsoOrderNumbers.O_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON AlsoProducts.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE tblCactuShop" & TABLE_PREFIX & "Versions.V_ProductID = " & P_ID & " AND AlsoVersions.V_ProductID NOT IN (" & strProductsDone & ") AND AlsoVersions.V_ProductID <> " & P_ID & " AND AlsoProducts.P_Name" & numLanguageID & " <> '' AND P_Live = 'y' AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND (SUP_Live <> 'n' OR SUP_Live IS NULL) GROUP BY AlsoProducts.P_ID, AlsoProducts.P_Name" & numLanguageID & " ORDER BY " if strDatabaseType = "mysql" then strQuery = strQuery & "TotalMatches" else strQuery = strQuery & "Count(*)" strQuery = LimitSQL(strQuery & " DESC", numPeopleWhoBought, false) else 'Only groups by one order. So items need to be purchased together, in the same order, to 'be grouped together if strDatabaseType = "mysql" then strQuery = "SELECT AlsoProducts.P_ID, AlsoProducts.P_Name" & numLanguageID & ", Count(AlsoProducts.P_ID) AS TotalMatches FROM ((((tblCactuShop" & TABLE_PREFIX & "Versions INNER JOIN tblCactuShop" & TABLE_PREFIX & "InvoiceRows ON tblCactuShop" & TABLE_PREFIX & "Versions.V_CodeNumber = tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_VersionCode) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Orders ON tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_OrderNumberID = tblCactuShop" & TABLE_PREFIX & "Orders.O_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "InvoiceRows AS AlsoInvoiceRows ON tblCactuShop" & TABLE_PREFIX & "Orders.O_ID = AlsoInvoiceRows.IR_OrderNumberID) INNER JOIN (tblCactuShop" & TABLE_PREFIX & "Versions AS AlsoVersions INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products AS AlsoProducts ON AlsoVersions.V_ProductID = AlsoProducts.P_ID) ON AlsoInvoiceRows.IR_VersionCode = AlsoVersions.V_CodeNumber) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON AlsoProducts.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE tblCactuShop" & TABLE_PREFIX & "Versions.V_ProductID = " & P_ID & " AND AlsoVersions.V_ProductID NOT IN (" & strProductsDone & ") AND AlsoVersions.V_ProductID <> " & P_ID & " AND P_Live = 'y' AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND AlsoProducts.P_Name" & numLanguageID & " <> '' AND (SUP_Live <> 'n' OR SUP_Live IS NULL) GROUP BY AlsoProducts.P_ID, AlsoProducts.P_Name" & CInt(numLanguageID) & " ORDER BY TotalMatches DESC LIMIT 0, " & numPeopleWhoBought else strQuery = "SELECT AlsoProducts.P_ID, AlsoProducts.P_Name" & numLanguageID & ", Count(AlsoProducts.P_ID) AS TotalMatches FROM ((((tblCactuShop" & TABLE_PREFIX & "Versions INNER JOIN tblCactuShop" & TABLE_PREFIX & "InvoiceRows ON tblCactuShop" & TABLE_PREFIX & "Versions.V_CodeNumber = tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_VersionCode) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Orders ON tblCactuShop" & TABLE_PREFIX & "InvoiceRows.IR_OrderNumberID = tblCactuShop" & TABLE_PREFIX & "Orders.O_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "InvoiceRows AS AlsoInvoiceRows ON tblCactuShop" & TABLE_PREFIX & "Orders.O_ID = AlsoInvoiceRows.IR_OrderNumberID) INNER JOIN (tblCactuShop" & TABLE_PREFIX & "Versions AS AlsoVersions INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products AS AlsoProducts ON AlsoVersions.V_ProductID = AlsoProducts.P_ID) ON AlsoInvoiceRows.IR_VersionCode = AlsoVersions.V_CodeNumber) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON AlsoProducts.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE tblCactuShop" & TABLE_PREFIX & "Versions.V_ProductID = " & P_ID & " AND AlsoVersions.V_ProductID NOT IN (" & strProductsDone & ") AND AlsoVersions.V_ProductID <> " & P_ID & " AND P_Live = 'y' AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND AlsoProducts.P_Name" & numLanguageID & " <> '' AND (SUP_Live <> 'n' OR SUP_Live IS NULL) GROUP BY AlsoProducts.P_ID, AlsoProducts.P_Name" & CInt(numLanguageID) & " ORDER BY Count(AlsoProducts.P_ID) DESC" end if end if Call ExecuteRS(strQuery, objRecordSet) If not (objRecordSet.BOF and objRecordSet.EOF) Then 'Write out the title If not blnDoneCrossSelling then response.Write strCarryOnShopping blnDoneCrossSelling = True End If %>

<% WriteString("ContentText_PeopleWhoBought") %>:

<% End If objRecordSet.Close end if '----------------------------------------- 'DO 'TRY THESE CATEGORIES' 'Lists all categories that this product 'is in, except the category we may be in '----------------------------------------- numTryTheseCategories = GetAppVar("trythesecategories") If numTryTheseCategories > 0 then strQuery = "SELECT tblCactuShop" & TABLE_PREFIX & "Categories.CAT_ID, tblCactuShop" & TABLE_PREFIX & "Categories.CAT_Name" & CInt(numLanguageID) & " FROM tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink INNER JOIN tblCactuShop" & TABLE_PREFIX & "Categories ON tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_CategoryID = tblCactuShop" & TABLE_PREFIX & "Categories.CAT_ID WHERE tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_ProductID = " & P_ID & " AND CAT_Live = 'y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ")" If CAT_ID <> 0 then strQuery = strQuery & " AND CAT_ID <> " & CAT_ID Call ExecuteRS(strQuery, objRecordSet) If not (objRecordSet.BOF and objRecordSet.EOF) Then 'Write out the title If not blnDoneCrossSelling then response.Write strCarryOnShopping blnDoneCrossSelling = True End If %>

<% WriteString("ContentText_TryTheseCategories") %>:

    <% numCount = 0 Do Until objRecordSet.EOF or numCount = numTryTheseCategories 'Get the category name numCount = numCount + 1 CAT_ID = objRecordSet("CAT_ID") %>
  • <%= strMothersHTML %><%= objRecordSet("CAT_Name" & CInt(numLanguageID)) %>
  • <% objRecordSet.MoveNext Loop %>
<% End If 'End people who bought... objRecordSet.Close End If 'If we did one or more cross-selling, close the table If blnDoneCrossSelling then response.Write "
" & vbcrlf response.Write "
" & vbcrlf end if '// product exists '----------------------------------------------- 'WRITE LAST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(1)) Set objRecordSetOptions = nothing Call EndPage() %>