<%@ LANGUAGE="VBSCRIPT" %> <% '********************* Note to developer *************** 'The output of this page will be in JavaScript format. 'To override this and to generate direct HTML output, 'type the URL into your browser's address box 'and APPEND it with the query string ' debug=true 'This allows you to examine its run-time contents. '******************************************************* '!!!WARNING!!! 'DO NOT EDIT THIS PAGE UNDER FRONTPAGE EDITOR. 'USE NOTEPAD INSTEAD 'HOW TO USE: 'INSERT the following code to your HTML pages: ' 'WHERE myproduct is the Reference Code for the product item. 'QUALIFY the "view_product.asp" with appropriate domain and path. 'SPECIAL CASES 'Search Box ' 'View Cart button ' 'Set to False to allow wildcard match at the end of the product id Session(DSN+"ExactMatch") = False 'If false, specify the field by which the result will be ordered. Session(DSN+"OrderBy") = "ProductDesc" 'Page Messages: Feel free to redefine them Session(DSN+"view_product"+"M1") = "Enter keywords to search." Session(DSN+"view_product"+"M2") = "Search" Session(DSN+"view_product"+"M3") = "Click to Find the match(s)." 'Page Settings: Const VIEWCART_IMG = "viewcart.gif" Const ADDITEM_IMG = "additem.gif" Const TEXT_FONT = "" Const IMAGE_DIR = "" Const POPUP = "yes" 'possible values "no" or "hide" %> <%Call CreateMyObject %> <% If IsObject(MyObject) Then MyObject.VIEWCART_IMG = VIEWCART_IMG MyObject.ADDITEM_IMG = ADDITEM_IMG MyObject.TEXT_FONT = TEXT_FONT MyObject.IMAGE_DIR = IMAGE_DIR End If %> <% Dim bGSTAdded, sGSTAdded 'This is typically for Australian businesses only. 'It queries the shopping cart to see if a GST inclusive price should be displayed. Function AddGSTToPrice(ByRef curPrice, ByRef rsCatalog, ByRef sGSTAdded) Dim rs, SQL, sStr AddGSTToPrice = False sGSTAdded = "" If IsNull(Session(DSN+"AddGSTToPrice")) Or Len(Session(DSN+"AddGSTToPrice")) = 0 Then Session(DSN+"AddGSTToPrice") = 0 SQL = "SELECT TaxRate FROM Admin WHERE StateProv = '-GST-' AND Country Is NOT NULL And TaxRate > 0" Call OpenRecordset(rs, SQL, connDSN, 3, 1) If Not rs.EOF Then Session(DSN+"AddGSTToPrice") = CDbl(rs.Fields("TaxRate").Value) End If rs.Close Set rs = Nothing End If If Session(DSN+"AddGSTToPrice") > 0 Then If IsNull(curPrice) Then Exit Function ElseIf Not IsNumeric(curPrice) Then Exit Function ElseIf Not IsObject(rsCatalog) Then 'Reley on previous call to determine if GST should be applied If bGSTAdded Then curPrice = CDbl(curPrice) * (1 + Session(DSN+"AddGSTToPrice")) End If Exit Function ElseIf Not IsNull(rsCatalog.Fields("Taxable").Value) Then sStr = LCase(CStr(rsCatalog.Fields("Taxable").Value)) If sStr = "no" Or sStr = "false" Or sStr = "0" Then sGSTAdded = " (No GST) " Exit Function End If End If curPrice = CDbl(curPrice) * (1 + Session(DSN+"AddGSTToPrice")) sGSTAdded = " (incl GST) " AddGSTToPrice = True End If End Function %> <% Call ProcessPage Function FormatSubmitTag(sImage, sWidth, sHeight, sBorder) If IsObject(MyObject) Then FormatSubmitTag = MyObject.FormatSubmitTag(sImage, sWidth, sHeight, sBorder) End If End Function Function FormatImageTag(sImage, sWidth, sHeight, sBorder) If IsObject(MyObject) Then FormatImageTag = MyObject.FormatImageTag(sImage, sWidth, sHeight, sBorder) End If End Function Sub OutputToPage(ByRef sOutput) If IsObject(MyObject) Then Call MyObject.OutputToPage(sOutput) End If End Sub Sub GetStockRs(ByRef rs, ByRef sOutput, sFormStart, sFormEnd) If IsObject(MyObject) Then Call MyObject.GetStockRs(rs, sOutput, sFormStart, sFormEnd) End If End Sub Function IsField(ByRef rs, sField) If IsObject(MyObject) Then IsField = MyObject.IsField1(rs, sField) End If End Function Function EncryptParam(sProductID, sParam) Dim objCyberShop Set objCyberShop = CreateObject("CyberShop.view_cart") If IsObject(objCyberShop) Then On Error Resume Next EncryptParam = objCyberShop.EncryptParam(sProductID, sParam, Session(DSN+"EncryptPassword")) If Err.Number <> 0 Then Err.Clear EncryptParam = sParam End If End If Set objCyberShop = Nothing End Function %> <% Sub ProcessPage() 'Page Variable Dim rs, sOutput, sFormStart, sFormEnd sOutput = "" Call GetStockRs(rs, sOutput, sFormStart, sFormEnd) If sOutput = "" And Len(Session(DSN+"ProductID")) <> 0 Then If POPUP <> "no" Then sFormStart = Replace(sFormStart, "
" Response.Write sOutput ElseIf IsObject(MyObject) Then Call MyObject.WriteToHTML1(Session, Response, sOutput) End If End Sub %> <% 'NOTE: The following function can be customized ' to your application. %> <% Function FormatOutput(ByRef rs) Dim sMyOutput, sStr, arrDields, i, crlf crlf = Chr(13) & Chr(10) On Error Resume Next 'Const sHiddenFields = "ProductID,ShippingType,ProductDesc,Price,TaxRate,BaseQuantity,Download,Coupon,Point,Bonus,DestEmail,Taxable,DeliveryMode" Const sHiddenFields = "ProductID,ProductType,ProductDesc,Price,TaxRate,BaseQuantity,Download,Coupon,Point,Bonus,DestEmail,Taxable,DeliveryMode" arrFields = Split(sHiddenFields,",") sMyOutput = "" For i = 0 To UBound(arrFields) sStr = "" If IsField(rs, Trim(arrFields(i))) Then If Not IsNull(rs.Fields(Trim(arrFields(i))).Value) Then sStr = CStr(rs.Fields(Trim(arrFields(i))).Value) 'Change ShippingType to ProductType if any If arrFields(i) = "ShippingType" Then arrFields(i) = "ProductType" End If sMyOutput = sMyOutput & "" & crlf End If End If Next If Session(DSN+"EncryptPrice") Then sMyOutput = sMyOutput & "" & crlf End If If IsArray(arrFields) Then Erase arrFields Const sDisplayFields = "ProductDesc,LargeImage,ProductInfo,Price,TaxRate,Point,Bonus,Quantity" 'Free free to customize the look and feel of the product page: arrFields = Split(sDisplayFields,",") sMyOutput = sMyOutput & "" & crlf For i = 0 To UBound(arrFields) If IsField(rs, Trim(arrFields(i))) Then If Not IsNull(rs.Fields(Trim(arrFields(i))).Value) Then sStr = CStr(rs.Fields(Trim(arrFields(i))).Value) Select Case Trim(arrFields(i)) Case "ProductDesc" sMyOutput = sMyOutput & "" & crlf Case "LargeImage" If InStr(1, sStr, ":", 1) = 0 And Left(sStr, 1) <> "/" Then sStr = IMAGE_DIR & sStr End If sMyOutput = sMyOutput & "" & crlf Case "ProductInfo" If InStr(1, sStr, ""))) = "" Then Dim j j = InStr(2, sStr, ">", 1) If j > 0 Then sStr = Mid(sStr, j+1) End If j = Len(sStr) - Len("") If j > 0 Then sStr = Left(sStr, j) Else sStr = "" End If sStr = "" Else sStr = "" sStr = Replace(sStr, Chr(10), Chr(10) & "
") End If sMyOutput = sMyOutput & sStr & crlf Case "Price" Dim curPrice curPrice = rs.Fields("Price").Value Call AddGSTToPrice(curPrice, rs, sGSTAdded) sMyOutput = sMyOutput & "" & crlf 'Case "ListPrice" If IsField(rs, "ListPrice") Then If Not IsNull(rs.Fields("ListPrice").Value) Then If CDbl(rs.Fields("ListPrice").Value) > CDbl(rs.Fields("Price").Value) Then curListPrice = CDbl(rs.Fields("ListPrice").Value) curPrice = rs.Fields("ListPrice").Value Call AddGSTToPrice(curPrice, rs, sGSTAdded) sMyOutput = sMyOutput & "" & crlf End If End If End If Call GetDiscountPrices(sMyOutput, rs) Case "TaxRate" sMyOutput = sMyOutput & "" & crlf Case "Point" If Session(DSN+"BuyerPoints") = True Then If CInt(sStr) > 0 Then sMyOutput = sMyOutput & "" & crlf End If End If Case "Bonus" If Session(DSN+"BuyerPoints") = True Then If CInt(sStr) > 0 Then sMyOutput = sMyOutput & "" & crlf End If End If Case "Quantity" If CInt(sStr) > 0 Then sMyOutput = sMyOutput & "" & crlf End If End Select End If End If Next If IsArray(arrFields) Then Erase arrFields sStr = FormatSubmitTag(ADDITEM_IMG,"","","0") sMyOutput = sMyOutput & "" & crlf sMyOutput = sMyOutput & "
" & TEXT_FONT & _ Server.HTMLEncode(sStr) & "
" & _ FormatImageTag(sStr,"","","0") & "" & TEXT_FONT & _ sStr & "
" & TEXT_FONT & _ Server.HTMLEncode(sStr) & "
" & TEXT_FONT _ & "Unit Price" & " " & TEXT_FONT & _ FormatPrice(Session, curPrice) & sGSTAdded & "
" & TEXT_FONT _ & "List Price" & " " & TEXT_FONT & _ "" & FormatPrice(Session, curPrice) & "" & _ "  " & FormatNumber(100*(CDbl(rs.Fields("ListPrice").Value) - CDbl(rs.Fields("Price").Value))/CDbl(rs.Fields("ListPrice").Value), 0, False) & "% Off!" & _ "
" & TEXT_FONT _ & "Tax Rate" & " " & TEXT_FONT & _ CDbl(sStr)*100 & "%
" & TEXT_FONT _ & "Buyer's Club" & " " & TEXT_FONT & _ sStr & " points to redeem
" & TEXT_FONT _ & "Buyer's Bonus" & " " & TEXT_FONT & _ sStr & " points
" & TEXT_FONT _ & "Quantity" & " " _ & "
 " & _ sStr & "
" & crlf FormatOutput = sMyOutput End Function Sub GetDiscountPrices(ByRef sMyOutput, ByRef rs) Dim fd, sStr, sQty For Each fd In rs.Fields If InStr(1, fd.Name, "DiscountFor", 1) = 1 Then sQty = Mid(fd.Name, 1 + Len("DiscountFor")) If Len(sQty) <> 0 And IsNumeric(sQty) And Not IsNull(fd.Value) Then sMyOutput = sMyOutput & "" & TEXT_FONT _ & "Discount For " & sQty & " 
" & TEXT_FONT & _ FormatPrice(Session, fd.Value) & _ "  " & FormatNumber(100*(CDbl(rs.Fields("Price").Value) - CDbl(fd.Value))/CDbl(rs.Fields("Price").Value), 0, False) & "% Saving!" & _ "" & crlf End If End If Next End Sub If POPUP <> "no" Then %> function SetProductID(frm) { var wndAddToCart = null; <%If POPUP = "hide" Then%> var sOptions = "top=10,left=" + (window.screen.width + 250) + ",width=220,height=120,scrollbars=no,resizable=no,menubar=no"; <%Else%> var sOptions = "top=10,left=" + (window.screen.width - 250) + ",width=220,height=120,scrollbars=no,resizable=no,menubar=no"; <%End If%> var sProd, obProd, i; if (frm.Rnd != null) { frm.Rnd.value = Math.round(Math.random()*100000); } if (frm.ProductID != null) { if (frm.ProductID[0] != null) { sProd = frm.ProductID[0].value; obProd = frm.ProductID[0]; } else { sProd = frm.ProductID.value; obProd = frm.ProductID; } } i = sProd.indexOf(", "); if (i >= 0 ) sProd = sProd.substring(0,i); for (i = 0; i < frm.elements.length; i++) { if (frm.elements[i].name != "Quantity" && (frm.elements[i].type.indexOf('select') >= 0 || frm.elements[i].type.indexOf('radio') >= 0)) sProd += ", " + frm.elements[i].selectedIndex; } obProd.value = sProd; wndAddToCart = window.open("","AddToCart",sOptions); if (wndAddToCart) { wndAddToCart.focus(); frm.target = "AddToCart"; i = frm.action.lastIndexOf('/'); frm.action = frm.action.substring(0, i+1) + 'view_cart2.asp'; } else frm.target = "_self"; } <% End If CloseDatabase %>