<% '************************************************************************* ' ASP Scripting: ' Filename: view_products_by_product_line_category.asp ' Written by: Wilbert Madarang ' Date: April 21, 2003 '************************************************************************* ' Description: View Products By Product Line Category '************************************************************************* %> <% 'Declare Variables Dim strProductLineId, strProductLineCategoryId, strPatternId 'Obtain Web Parameters strProductLineId = Request( "product_line_id" ) strProductLineCategoryId = Request( "product_line_category_id" ) strPatternId = Request( "patternId" ) If strPatternId = "" Then strPatternId = 0 End If %> Welcome to Charister.com

   <% 'Print Pattern Images Call PrintProductLineCategoryImages( strProductLineCategoryId ) %>
<% Call PrintProductsByProductLineCategory() %>
<% '************************************************************************* ' Function: PrintProductLineCategoryImage() ' Description: prints the pattern Images ' Parameters: strProductLineCategoryId ' Returns: none ' Written by: Wilbert Madarang ' Date: February 4, 2003 '************************************************************************* Function PrintProductLineCategoryImages( strProductLineCategoryId ) Dim strSQL, strProductLineCategoryThumbnailLocation, strProductLineCategoryImageLocation, rs 'Prepare SQL Statement strSQL = "Select * FROM dirProductLineCategories WHERE plCategoryId=" & strProductLineCategoryId Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() 'Get Image Locations If NOT (rs.EOF AND rs.BOF) Then strProductLineCategoryThumbnailLocation = rs.Fields( "plCategory_Thumbnail_Location" ) strProductLineCategoryImageLocation = rs.Fields( "plCategory_Image_Location" ) Else strProductLineCategoryThumbnailLocation = "" strProductLineCategoryImageLocation = "" End If 'Write Headers strProductLineCategoryName = getProductLineCategoryName( strProductLineCategoryId ) Response.Write "" & strProductLineCategoryName & "

  " &vbCrLf 'Print Images Response.Write "  

" & vbCrLf '************************************** ' Modification 1.0 on March 15 by WM ' Modification 1.1 on March 29, 2003 by WM '************************************** 'Response.Write "   

" 'Response.Write "   

" ' Response.Write "  

" ' Response.Write "
" ' Response.Write "" ' Response.Write "     

" Response.Write "     " ' Response.Write "
" '************************************** ' End of Modification 1.0, March 15 by WM '************************************** End Function '************************************************************************* ' Function: PrintProductsByProductLineCategory() ' Description: prints patterns by product line category ' Parameters: none ' Returns: none ' Written by: Wilbert Madarang ' Date: April 21, 2003 '************************************************************************* Function PrintProductsByProductLineCategory() Dim strSQL, strTable, strConstraint, strLocalPatternId, rs Dim strCurrencyLabel Dim nProductPrice 'Prepare Currency Label strCurrencyLabel = getCurrencyLabel() 'Prepare SQL statements strRegularPriceFieldName = getRegularPriceFieldName() 'US or Cdn Price strSalePriceFieldName = getSalePriceFieldName() 'US or Cdn Price strDisplayOrder = " ORDER BY dirProducts.patternId" strConstraint = " WHERE productLineId=" & strProductLineId & " AND productLineCategoryId=" & strProductLineCategoryId 'strColumnNames = " productId, productName, " & strRegularPriceFieldName & "," & strSalePriceFieldName strTable = "dirProducts INNER JOIN dirPatterns ON dirProducts.patternId=dirPatterns.patternId " strSQL = "SELECT * FROM " & strTable & strConstraint & strDisplayOrder 'Open Data Connections Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() 'Write Headers Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Call AddLinkToCart() Response.Write "" & vbCrLf Response.Write "
" & vbCrLf strProductLineCategoryName = getProductLineCategoryName( strProductLineCategoryId ) Response.Write "" & strProductLineCategoryName & "" &vbCrLf Response.Write "
" & vbCrLf Response.Write "
" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Write Data DO WHILE NOT rs.EOF '************************************************************************ ' Modified by WM - March 29, 2003 '************************************************************************ ' 1. Added Bold Attributes to strPatternName. ' 2. Display Product Code instead of Product ID ' 3. Added Font Color Attributes to strProductCode ' 4. Changed field names for currency to nProductSalePrice, nProductRegularPrice ' from strProductSalePrice, strProductRegularPrice ' 5. Changed logic for displaying Sale price ' - don't use LEN(strProductSalePrice) > 0 ' - use (nProductSalePrice) > 0 '************************************************************************ 'Obtain Fields strProductId = rs.Fields("productId") strProductName = rs.Fields( "productName" ) strProductCode = rs.Fields( "productCode" ) strPatternId = rs.Fields( "patternId" ) strPatternName = rs.Fields( "patternName" ) nProductRegularPrice = rs.Fields( strRegularPriceFieldName ) nProductSalePrice = rs.Fields( strSalePriceFieldName ) nProductPrice = getProductPrice( nProductRegularPrice, nProductSalePrice ) 'Define Form Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Write Product Information Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Write Color Permutations Response.Write "" & vbCrLf 'Write Quantity Response.Write "" & vbCrLf 'Write Add to Cart Response.Write "" & vbCrLf 'End Row Response.Write "" & vbCrLf Response.Write "" & vbCrLf rs.MoveNext LOOP Response.Write "
PatternsColorsQuantityAdd to Cart
" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & strProductName & "
" & vbCrLf 'Response.Write strPatternName & "
" & vbCrLf 'Response.Write "" & strPatternName & "
" & vbCrLf Response.Write "Price: " & strCurrencyLabel & FormatCurrency(nProductRegularPrice, 2) & "
" & vbCrLf If ( nProductSalePrice ) > 0 Then '******************************************** ' Added by WM, November 24, 2003 ' Added Red Color to Sale '******************************************** Response.Write "" & vbCrLf Response.Write "Sale: " & strCurrencyLabel & FormatCurrency(nProductSalePrice, 2) & "
" & vbCrLf Response.Write "
" & vbCrLf '******************************************** ' End of Addition by WM, Nov 24, 2003 '******************************************** End If 'Response.Write "Product ID: " & strProductId & "

" & vbCrLf Response.Write "Product Code: " & strProductCode & "

" & vbCrLf Response.Write "
" & vbCrLf Response.Write "
" & vbCrLf Call PrintColorSelectionListByPattern( strProductId ) Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "
" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Call AddLinkToCart() Response.Write "" & vbCrLf Response.Write "
" & vbCrLf End Function '************************************************************************* ' Function: PrintColorSelectionListByPattern() ' Description: prints the products by pattern provided ' Parameters: strProductId ' Returns: none ' Written by: Wilbert Madarang ' Date: February 4, 2003 '************************************************************************* ' Modified by WM - November 1, 2003 '************************************************************************ ' 1. Added color as a hidden web parameter into the shopping cart form. '************************************************************************ Function PrintColorSelectionListByPattern( strProductId ) Dim strSQL, strTable, strConstraint, rs, strUrl 'Prepare SQL strConstraint = " WHERE rel_Product_Color.productId=" & strProductId strTable = "rel_Product_Color INNER JOIN dirColors ON rel_Product_Color.colorId=dirColors.colorId" strSQL = "SELECT rel_Product_Color.colorId, dirColors.colorName FROM " & strTable & strConstraint 'Call SQL Statement Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() 'Assess if there are Records If rs.EOF AND rs.BOF Then Response.Write "
 " & vbCrLf Exit Function End If 'Print Colors Selection List 'Response.Write "" & vbCrLf strUrl = "" DO WHILE NOT rs.EOF strColorId = rs.Fields( "colorId" ) strColorName = rs.Fields( "colorName" ) 'Response.Write "" Response.Write "" rs.MoveNext LOOP Response.Write "" & vbCrLf End Function '************************************************************************* ' Function: getRegularPriceFieldName ' Description: gets the Regular Price FieldName ' Parameters: none ' Returns: none ' Written by: Wilbert Madarang ' Date: February 8, 2003 '************************************************************************* ' Modified: November 8, 2003 ' Changed references from "MyCountry" to "MyCurrency" '************************************************************************* Function getRegularPriceFieldName Dim strFieldName If session( "MyCurrency" ) = "canada" Then strFieldName = "product_Reg_Price_Cdn" Else strFieldName = "product_Reg_Price_US" End If getRegularPriceFieldName = strFieldName End Function '************************************************************************* ' Function: getSalePriceFieldName ' Description: gets the Sale Price FieldName ' Parameters: none ' Returns: the Field Name, in either US or Canadian Currency ' Written by: Wilbert Madarang ' Date: February 8, 2003 '************************************************************************* ' Modified: November 8, 2003 ' Changed references from "MyCountry" to "MyCurrency" '************************************************************************* Function getSalePriceFieldName Dim strFieldName If session( "MyCurrency" ) = "canada" Then strFieldName = "product_Sale_Price_Cdn" Else strFieldName = "product_Sale_Price_US" End If getSalePriceFieldName = strFieldName End Function '************************************************************************* ' Function: getProductLineCategoryName ' Description: gets the Product Line Category Name ' Parameters: product line category id ' Returns: product line category name ' Written by: Wilbert Madarang ' Date: February 8, 2003 '************************************************************************* Function getProductLineCategoryName( strProductLineCategoryId ) Dim strSQL, rs, strProductLineCategoryName strSQL = "SELECT plCategoryName FROM dirProductLineCategories WHERE plCategoryId=" & strProductLineCategoryId Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() If NOT (rs.EOF AND rs.BOF) Then strProductLineCategoryName = rs.Fields( "plCategoryName" ) Else strProductLineCategoryName = "" End If getProductLineCategoryName = strProductLineCategoryName End Function '************************************************************************* ' Function: getCurrencyLabel ' Description: gets Currency Label ' Parameters: none ' Returns: returns Currency Label ' Written by: Wilbert Madarang ' Date: March 16, 2003 '************************************************************************* ' Modified: November 8, 2003 ' Changed references from "MyCountry" to "MyCurrency" '************************************************************************* Function getCurrencyLabel Dim strCurrency, strCurrencyLabel 'Obtain the Session Information strCurrency = Session("MyCurrency") If strCurrency = "" OR IsNull( strCurrency ) Then strCurrency = DEFAULT_COUNTRY End If 'Get Currency Label If strCurrency = "canada" Then strCurrencyLabel = CURRENCY_LABEL_CANADIAN Else strCurrencyLabel = CURRENCY_LABEL_US End If getCurrencyLabel = strCurrencyLabel End Function '************************************************************************* ' Function: getProductPrice ' Description: gets the Product Price ' Parameters: regular price, sale price ' Returns: returns the price ' Written by: Wilbert Madarang ' Date: May 7, 2003 '************************************************************************* Function getProductPrice( nProductRegularPrice, nProductSalePrice ) Dim nProductPrice If ( nProductSalePrice ) > 0 Then nProductPrice = nProductSalePrice Else nProductPrice = nProductRegularPrice End If getProductPrice = nProductPrice End Function '************************************************************************* ' Function: AddLinkToCart ' Description: Adds a Link to the Shopping Cart ' Parameters: regular price, sale price ' Returns: returns the price ' Written by: Wilbert Madarang ' Date: May 7, 2003 '************************************************************************* Function AddLinkToCart ' Response.Write "View Shopping Cart" & vbCrLf Response.Write "" & vbCrLf Response.Write "
" & vbCrLf Response.Write "" & vbCrLf End Function %>