<%@LANGUAGE="VBSCRIPT"%> <% 'Option Explicit %> <% '================================================================ 'Application Info: ' Cartweaver© 2002 - 2005, All Rights Reserved. 'Developer Info: ' Application Dynamics Inc. ' 1560 NE 10th ' East Wenatchee, WA 98802 'Support Info: http://www.cartweaver.com/go/asphelp ' 'Cartweaver Version: 2.2 - Date: 08/07/2005 '================================================================ 'Name: Application.asp 'DESCRIPTION: The Application.asp file is the root file for the ' entire Cartweaver application. This file defines the store-wide ' variables that will control your cart, and also includes all of ' the necessary function files to make the cart function. You can ' edit all of the settings on this page manually or through the ' Cartweaver 2 Setup Server Behavior. Variables are listed in the ' order in which the Cartweaver 2 Setup Server Behavior adds them ' to the page. '================================================================ '*Do Not Remove This Line* Prevents extraneous %@LANGUAGE="VBSCRIPT"% declaration. '=== Start Cartweaver Variables === Const datasource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inetpub\ncwdigital\_private\ncwdata.mdb;User ID=;Password=;" Const dbType = "Access" Dim websiteURL : websiteURL = "http://www.ncwdigital.com" Dim websiteSSLURL : websiteSSLURL = "https://www.ncwdigital.com" Dim onSubmitAction : onSubmitAction = "Confirm" Dim targetResults : targetResults = "Results.asp" Dim recordsAtATime : recordsAtATime = "10" Dim targetDetails : targetDetails = "Details.asp" Dim detailsDisplay : detailsDisplay = "Advanced" Dim targetGoToCart : targetGoToCart = "ShowCart.asp" Dim targetCheckout : targetCheckout = "OrderForm.asp" Dim targetConfirmOrder : targetConfirmOrder = "Confirmation.asp" Dim ImageThumbFolder : ImageThumbFolder = "cw2/Assets/product_thumb/" Dim ImageLargeFolder : ImageLargeFolder = "cw2/Assets/product_full/" Const cwLocale = "1033" Const uploadCom = "" Const mailObj = "CDOSYS" Const mailServer = "mail.ncwdigital.com" Dim paymentAuthType : paymentAuthType = "gateway" Dim paymentAuthName : paymentAuthName = "CWIncAuthorizeNet.asp" Dim enableErrorHandling : enableErrorHandling = False 'False for testing, True for live sites Dim cwDebug : cwDebug = False 'True for testing, False for live sites Const debugPassword = "debug" '=== End Cartweaver Variables === 'Include all Cartweaver application functions %> <% '================================================================ 'Application Info: ' Cartweaver© 2002 - 2005, All Rights Reserved. 'Developer Info: ' Application Dynamics Inc. ' 1560 NE 10th ' East Wenatchee, WA 98802 'Support Info: http://www.cartweaver.com/go/asphelp ' 'Cartweaver Version: 2.1 - Date: 05/14/2005 '================================================================ 'Name: Variables Include 'Description: ' This page declares all of the variables used throughout the ' Cartweaver application. This allows the use of Option Explicit ' in the Cartweaver app in order to prevent misnamed variables ' and variable clashing. '================================================================ '*Do Not Remove This Line* Prevents extraneous %@LANGUAGE="VBSCRIPT"% declaration from being added by Dreamweaver. '================================================================ 'Global Use Variables '================================================================ 'Global variables used through the application Dim ThisPage Dim ThisPageQS Dim ShipCalcType Dim strSQL 'Used to store temporary SQL strings for CWOpenQuery Dim i, x, y 'Global count variables, used for looping throughout the cart Dim strDebugOutput 'Use to maintain Debug output Dim cwCart 'cwObjCartweaver Object Dim cwSearchObj 'cwSearch Object Dim TickCount 'Ticker for page execution time 'Variables for manipulating images: Dim SiteRoot, ImagePath, ImageSRC 'Paging Variables Dim PagingURL Dim PageNum_Results Dim MaxRows_Results Dim StartRow_Results Dim EndRow_Results Dim TotalPages_Results '================================================================ 'CWIncResults Variables '================================================================ Dim rsCWGetResults Dim ResultCount '================================================================ 'CWIncDetails Variables '================================================================ Dim rsCWGetProduct, query_rsCWGetProduct Dim rsCWGetUpsell, query_rsCWGetUpsell Dim rsCWGetSKUs, query_rsCWGetSKUs Dim bolDisplayUpsell Dim intUpsellCount Dim intQuantity Dim strResult Dim strAddToCartType Dim intProductID '================================================================ 'CWIncOrderForm Variables '================================================================ Dim rsCWGetCart Dim rsCWGetCustData Dim rsCWGetBillTo Dim rsCWGetShipTo Dim rsCWGetCCards Dim rsCWCartOptions Dim rsCWShipList Dim bolHasCart Dim FieldError, FieldErrorText Dim qtyAdded Dim StockAlert Dim TransactionMessage Dim cstCCardHolderName Dim cstCCardType Dim cstCCNumber Dim cstCCV Dim cstExprMonth Dim cstExprYr Dim shipExtension Dim OrderTotal Dim TaxAmt Dim ShipTotal Dim CartSubTotal Dim CartWeightTotal '================================================================ 'CWIncShowCart Variables '================================================================ Dim rsCWGetCountries, query_rsCWGetCountries Dim rsCWGetStates, query_rsCWGetStates Dim rsCWGetCustomerData Dim rsCWBillState, rsCWShipState Dim billStateID, billCountryID Dim shipStateID, shipCountryID Dim fieldInvalid, loginError, usernameError, emailError Dim loginResult, passwordFound Dim customerID Dim cstFirstName, cstLastName Dim cstAddress1, cstAddress2 Dim cstCity, cstStateProv, cstCountry, cstZip Dim cstPhone, cstEmail Dim cstUsername, cstPassword, cstPasswordConfirm Dim cstShpName, cstShpAddress1, cstShpAddress2 Dim cstShpCity, cstShpStateProv, cstShpCountry, cstShpZip cstCountry = 0 cstShpCountry = 0 '================================================================ 'CWIncConfirmation Variables '================================================================ Dim orderID Dim EmailContents Dim rsCWOrder, query_rsCWOrder Dim rsCWOptions, query_rsCWOptions %> <% '================================================================ 'Application Info: ' Cartweaver© 2002 - 2005, All Rights Reserved. 'Developer Info: ' Application Dynamics Inc. ' 1560 NE 10th ' East Wenatchee, WA 98802 'Support Info: http://www.cartweaver.com/go/asphelp ' 'Cartweaver Version: 2.2 - Date: 08/07/2005 '================================================================ 'Name: CWIncGlobalSettings.asp 'Description: ' Sets all of the global variables used throughout the ' cartweaver application, including DSNs and ' company information. This file is called from the ' Application.asp file via an include. '================================================================ '*Do Not Remove This Line* Prevents extraneous %@LANGUAGE="VBSCRIPT"% declaration from being added by Dreamweaver. 'Start timer for page execution time TickCount = Timer 'Set the locale ID for the entire application Session.LCID = cwLocale 'Set the shipping calculation type preferance. Default is "localcalc" ShipCalcType = "localcalc" 'Set Headers to prevent browser cache issues Response.CacheControl = "no-cache" Response.AddHeader "Pragma", "no-cache" Response.Expires = -1 'Clean up URL variables 'Set URLs for the store pages. The websiteSSLURL variable determines where 'secure pages should be loaded. These should be absolute paths, including the 'trailing slash. targetGoToCart = targetGoToCart & "?cart=" & Request.Cookies("CartID") targetCheckOut = targetCheckOut & "?cart=" & Request.Cookies("CartID") If websiteSSLURL = "" Then websiteSSLURL = websiteURL If Len(websiteSSLURL) <> 0 AND Right(websiteSSLURL,1) <> "/" Then websiteSSLURL = websiteSSLURL & "/" End If If Len(websiteURL) <> 0 AND Right(websiteURL,1) <> "/" Then websiteURL = websiteURL & "/" End If 'Add the relevant SSL information to the target URLs Dim regEx Set regEx = New RegExp With regEx .Pattern = "http[s]?\:\/\/" .IgnoreCase = True .Global = True End With If websiteSSLURL <> "" Then If NOT regEx.Test(targetCheckOut) Then targetCheckout = websiteSSLURL & targetCheckout If NOT regEx.Test(targetGoToCart) Then targetGoToCart = websiteSSLURL & targetGoToCart If NOT regEx.Test(targetConfirmOrder) Then targetConfirmOrder = websiteSSLURL & targetConfirmOrder End If 'websiteSSLURL <> "" If websiteURL <> "" Then If NOT regEx.Test(targetResults) Then targetResults = websiteURL & targetResults If NOT regEx.Test(targetDetails) Then targetDetails = websiteURL & targetDetails End If 'websiteURL <> "" Set regEx = nothing 'Set Store/Company information in Application Variables ---> Application.Lock() 'If the companyname application variable isn't set or the user has 'requested to reset the application variables If application("companyname") = "" OR LCase(Request.QueryString("ResetApplication")) = "yes" Then 'Get the data from the Database Dim rsGetCompInfo Set rsGetCompInfo = CWOpenQuery("SELECT * FROM tbl_companyinfo",datasource) '//Set Company information into the Application Scope // Application("CompanyName") = rsGetCompInfo("comp_Name") Application("CompanyAddress1") = rsGetCompInfo("comp_Address1") Application("CompanyAddress2") = rsGetCompInfo("comp_Address2") Application("CompanyCity") = rsGetCompInfo("comp_City") Application("CompanyState") = rsGetCompInfo("comp_State") Application("CompanyZip") = rsGetCompInfo("comp_Zip") 'Set Company Contact Information Application("CompanyPhone") = rsGetCompInfo("comp_Phone") Application("CompanyFax") = rsGetCompInfo("comp_Fax") Application("CompanyEmail") = rsGetCompInfo("comp_Email") 'Set whether or not to display Cross Sell links on Detals page Application("ShowUpsell") = rsGetCompInfo("comp_ShowUpSell") 'Set whether or not to allow backorders Application("AllowBackorders") = rsGetCompInfo("comp_AllowBackorders") 'Set Shipping Criteria 'These variables determine how shipping will be calculated. 'By Base rate, weight range or location extension or a combination 'of these. These variables are set in the company Information 'form in the Admin section. Application("EnableShipping") = rsGetCompInfo("comp_EnableShipping") Application("ChargeShipBase") = rsGetCompInfo("comp_ChargeBase") Application("ChargeShipByWeight") = rsGetCompInfo("comp_ChargeWeight") Application("ChargeShipExtension") = rsGetCompInfo("comp_ChargeExtension") rsGetCompInfo.Close() Set rsGetCompInfo = Nothing End If Application.UnLock() 'ThisPage variable is used to create a link or form action that links back to the current file. ThisPage = Request.ServerVariables("SCRIPT_NAME") 'Add the query string If Request.QueryString <> "" Then ThisPageQS = ThisPage & "?" & Request.Querystring Else ThisPageQS = ThisPage End If 'If the user has chosen to logout, clear the session completely. If Request.QueryString("logout") <> "" Then Session.Abandon() Response.Redirect(ThisPage & "?" & cwKeepURL("logout")) End If 'Determine whether to display debug information If Session("debug") = "" Then Session("debug") = False : Session("debugStatus") = "ON" If Request.QueryString("debug") <> "" Then If Request.QueryString("debug") = debugPassword AND CBool(Session("debug")) = False Then Session("debug") = True Session("debugStatus") = "OFF" Else Session("debug") = False Session("debugStatus") = "ON" End If Response.Redirect(thisPage & "?" & cwKeepURL("debug")) End If SiteRoot = Request.ServerVariables("SCRIPT_NAME") SiteRoot = Left(SiteRoot,InStrRev(SiteRoot,"/")) ImageThumbFolder = SiteRoot & ImageThumbFolder ImageLargeFolder = SiteRoot & ImageLargeFolder 'Set paymentAuthType to all lower case for comparison purposes paymentAuthType = LCase(paymentAuthType) cwDebugger "SiteRoot: " & SiteRoot cwDebugger "ImageThumbFolder: " & ImageThumbFolder cwDebugger "ImageLargeFolder: " & ImageLargeFolder If enableErrorHandling Then On Error Resume Next %> <% '================================================================ 'Application Info: ' Cartweaver© 2002 - 2005, All Rights Reserved. 'Developer Info: ' Application Dynamics Inc. ' 1560 NE 10th ' East Wenatchee, WA 98802 'Support Info: http://www.cartweaver.com/go/asphelp ' 'Cartweaver Version: 2.0 - Date: 11/20/2004 '================================================================ 'Name: Cartweaver Search Object 'Description: This object generates several different types of ' searches and will display the type of search based on the ' properties chosen by the developer. The name of the action page, ' or target page for the search links or forms is set by the ' developer and stored in the Application.asp file. The Search ' object can be placed on any page in your Cartweaver store. ' Placement is dependant on where you'd like the text navigation ' links or the search form. The syntax for this object can be ' generated using the Cartweaver 2 Search/Navigation Server ' Behavior. 'PROPERTIES: 'SearchType: This property controls the type of search that ' is displayed. Valid values are "Links" and "Form". The Form ' search type displays a search form with the requested form ' fields passed through the Form related Arguments. The Links ' search type displays a list of links for each category ' formatted with the Links related Arguments. 'ActionPage: The page to submit the search criteria to. This ' value is most often the targetResults variable as defined ' in Application.asp, but may be any valid URL path string. 'The Search object has a number of properties for both Link ' and Form style searches. The properties are grouped below ' based on the type of search to display. 'Link Related Properties 'AllCategoriesLabel (Optional): The label used for the All ' Categories link. The default value is All. 'SelectedStart (Optional): Determines the string to be ' placed before a selected link. You can pass HTML code ' through this property, but all quotes must be escaped. ' The default value is . 'SelectedEnd: (Optional): Determines the string to be placed ' after a selected link. You can pass HTML code through ' this property, but all quotes must be escaped. The ' default value is . 'Separator (Optional): Determines the string to be placed ' between links when the Links SearchType is used. If you ' want to display links vertically you can pass HTML code, ' such as the
tag, through this attribute, but all ' quotes bust be escaped. The default value is a pipe ' symbol ( | ). 'Note: The SelectedStart, SelectedEnd, and Separator properties ' allow HTML values, but they must have quotes properly escaped ' (by doubling them). Example: ' for . 'Form Related Properties 'FormID (Optional): The form ID to be applied to the
tag. ' The default value is Search. 'ButtonLabel (Optional): The text to be used for the submit ' button of the search form. The default value is Search. 'DisplayCategory (Optional): Determines whether a category ' field is output. Valid values are True or ' False. The default value is False. 'SecondaryLabel (Optional): The text to use for the All ' Secondary Categories entry of the select field. The default ' value is All secondary categories. '================================================================ '*Do Not Remove This Line* Prevents extraneous %@LANGUAGE="VBSCRIPT"% declaration from being added by Dreamweaver. Class cwSearch Dim strSearchType, strActionPage, x Dim strAllCatLabel, strSeparator Dim strSelectedStart, strSelectedEnd Dim strFormID, strButtonLabel Dim bolKeywords, strKeywordsLabel Dim bolCategory, strCategoryLabel Dim bolSecondary, strSecondaryLabel Private Sub Class_Initialize() 'Set all default values strAllCatLabel = "All" strSeparator = " | " strSelectedStart = "" strSelectedEnd = "" strButtonLabel = "Search" strFormID = "Search" bolKeywords = False strKeywordsLabel = "Enter Keywords" bolCategory = False strCategoryLabel = "All Categories" bolSecondary = False strSecondaryLabel = "All Secondary Categories" strActionPage = targetResults End Sub Private Sub Class_Terminate() 'No action necessary. End Sub Public Property Let SearchType(ByVal str) 'This property sets the search type. strSearchType = str End Property Public Property Get SearchType 'This property returns the search type. SearchType = strSearchType End Property Public Property Let ActionPage(ByVal str) 'This property sets the action page. strActionPage = str End Property Public Property Get ActionPage 'This property returns the action page. ActionPage = strActionPage End Property Public Property Let FormID(ByVal str) 'This property sets the form id for form searches. strFormID = str End Property Public Property Get FormID 'This property returns the form id. ActionPage = strFormID End Property Public Property Let ButtonLabel(ByVal str) 'This property sets the button label for form searches. strButtonLabel = str End Property Public Property Get ButtonLabel 'This property returns the button label for form searches. ButtonLabel = strButtonLabel End Property Public Property Let DisplayKeywords(ByVal str) 'This property determines if the keywords input field is displayed. bolKeywords = str End Property Public Property Get DisplayKeywords 'This property returns if the keywords input field is displayed. DisplayKeywords = bolKeywords End Property Public Property Let KeywordsLabel(ByVal str) 'This property sets the label for the keywords input field. strKeywordsLabel = str End Property Public Property Get KeywordsLabel 'This property returns the label for the keywords input field. KeywordsLabel = strKeywordsLabel End Property Public Property Let DisplayCategory(ByVal str) 'This property determines if the categories select field is displayed. bolCategory = str End Property Public Property Get DisplayCategory 'This property returns if the categories select field is displayed. DisplayCategory = bolCategory End Property Public Property Let CategoryLabel(ByVal str) 'This property sets the label for the categories select field. strCategoryLabel = str End Property Public Property Get CategoryLabel 'This property returns the label for the categories select field. CategoryLabel = strCategoryLabel End Property Public Property Let DisplaySecondary(ByVal str) 'This property determines if the secondary categories select field is displayed. bolSecondary = str End Property Public Property Get DisplaySecondary 'This property returns if the secondary categories select field is displayed. DisplaySecondary = bolSecondary End Property Public Property Let SecondaryLabel(ByVal str) 'This property sets the label for the secondary categories select field. strSecondaryLabel = str End Property Public Property Get SecondaryLabel 'This property returns the secondary categories select field label. SecondaryLabel = strSecondaryLabel End Property Public Property Let AllCategoriesLabel(ByVal str) 'This property sets the text for the All Categories link. strAllCatLabel = str End Property Public Property Get AllCategoriesLabel 'This property returns the text for the All Categories link. AllCategoriesLabel = strAllCatLabel End Property Public Property Let Separator(ByVal str) 'This property sets the text used for link separators. strSeparator = str End Property Public Property Get Separator 'This property returns the text used for link separators. Separator = strSeparator End Property Public Property Let SelectedStart(ByVal str) 'This property sets the text for the selected start tag. strSelectedStart = str End Property Public Property Get SelectedStart 'This property returns the text for the selected start tag. SelectedStart = strSelectedStart End Property Public Property Let SelectedEnd(ByVal str) 'This property sets the text for the selected start tag. strSelectedEnd = str End Property Public Property Get SelectedEnd 'This property returns the text for the selected start tag. SelectedEnd = strSelectedEnd End Property Public Function Display() 'This method generates the HTML for the desired search type ' and returns the HTML back to the calling page as a string. ' There are no arguments for this method. If strActionPage = "" Then Display = "ERROR: you must specify an ActionPage for your search." : Exit Function 'Set search defaults Dim strKeywordSearch Dim strCategorySearch : strCategorySearch = 0 Dim strSecondarySearch : strSecondarySearch = 0 If Request.QueryString("keywords") <> "" Then strKeywordSearch = Request.QueryString("keywords") If Request.QueryString("category") <> "" AND IsNumeric(Request.QueryString("category")) Then strCategorySearch = Request.QueryString("category") If Request.QueryString("secondary") <> "" AND IsNumeric(Request.QueryString("secondary")) Then strSecondarySearch = Request.QueryString("secondary") strCategorySearch = CInt(strCategorySearch) strSecondarySearch = CInt(strSecondarySearch) 'If the form has been submitted and it's not the default text, 'then set the value for the keywordslabel to the submitted value If Request.QueryString("keywords") <> "" AND Request.QueryString("keywords") <> strKeywordsLabel Then strKeywordsLabel = Request.QueryString("keywords") End If 'If we're displaying links or the category search field, then get a category list Dim rsGetCategories If strSearchType = "Links" OR bolCategory Then Set rsGetCategories = cwOpenQuery("SELECT category_ID, category_Name FROM tbl_prdtcategories WHERE category_archive = " & cwBoolSQL(False) & " ORDER BY category_SortOrder, category_Name",datasource) End If 'If we're displaying secondary categories, then get a secondary category list Dim rsSecondaryCategories If bolSecondary Then Set rsSecondaryCategories = cwOpenQuery("SELECT scndctgry_ID, scndctgry_Name FROM tbl_prdtscndcats WHERE scndctgry_Archive = " & cwBoolSQL(False) & " ORDER BY scndctgry_Sort, scndctgry_Name",datasource) End If 'BEGIN SEARCH TYPE SELECTION Select Case strSearchType 'SEARCH BY CATEGORY - TEXT LINKS Case "Links" If strCategorySearch = 0 AND Request.QueryString("category") <> "" Then Display = Display & (strSelectedStart) If strAllCatLabel <> "" Then Display = Display & ("" & strAllCatLabel & "") If strCategorySearch = 0 AND Request.QueryString("category") <> "" Then Display = Display & (strSelectedEnd) Do While NOT rsGetCategories.EOF If rsGetCategories("category_id") <> 1 Then x = x + 1 If strAllCatLabel <> "" OR x > 1 Then Display = Display & (strSeparator) If rsGetCategories("category_id") = strCategorySearch AND Request.QueryString("category") <> "" Then Display = Display & (strSelectedStart) Display = Display & ("" & rsGetCategories("category_Name") & "") If rsGetCategories("category_id") = strCategorySearch AND Request.QueryString("category") <> "" Then Display = Display & (strSelectedEnd) End If rsGetCategories.MoveNext() Loop 'SEARCH BY FORM Case "Form" Display = Display & ("") If bolKeywords Then Display = Display & ("") If bolCategory Then Display = Display & ("") End If If bolSecondary Then Display = Display & (" ") End If Display = Display & ("") Display = Display & ("
") End Select 'Destroy our recordsets. CWCloseRecordset(rsGetCategories) CWCloseRecordset(rsSecondaryCategories) End Function End Class %> <% '================================================================ 'Application Info: ' Cartweaver© 2002 - 2005, All Rights Reserved. 'Developer Info: ' Application Dynamics Inc. ' 1560 NE 10th ' East Wenatchee, WA 98802 'Support Info: http://www.cartweaver.com/go/asphelp ' 'Cartweaver Version: 2.4 - Date: 11/27/2005 '======================================================================= 'Name: Cartweaver Functions Library 'Description: ' This file contains all common functions used throughout the ' Cartweaver application. '======================================================================= '*Do Not Remove This Line* Prevents extraneous %@LANGUAGE="VBSCRIPT"% declaration from being added by Dreamweaver. '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 'Query Functions 'The following functions handle all query operations in Cartweaver '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Function cwCleanString(str) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwCleanString 'DESCRIPTION: Removes single quotes (') from string values and replaces ' them with double single quotes ('') to prevent SQL injection attacks ' against the application. Use on all values passed through querystring ' and form values to your database. 'ARGUMENTS 'str: The str argument contains the text that will be searched for ' single quotes. 'RETURNS 'A string with all single quotes replaced with double single quotes. 'EXAMPLES 'Replace single quotes in a user submitted form field. 'cwCleanString(Request.Form("MyFormField")) 'Replace single quotes in a querystring. 'cwCleanString(Request.Querystring("MyURLValue")) '--------------------------------------------------------------------- cwCleanString = Replace(str,"'","''") End Function 'cwCleanString Function cwBoolSQL(str) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwBoolSQL 'DESCRIPTION: Returns a True/False value, based on the string provided, ' that is appropriate for the defined database type. The strings "True" ' and "False" are returned for Access databases, while 1 and 0 are ' returned for SQL databases. 'ARGUMENTS 'str: The str argument contains the text that will be checked for true ' and false values using the CBool function. 'RETURNS 'A string containing a valid True/False value for the user's database. 'EXAMPLES 'Return a true/false value baesd on a recordset field. 'cwBoolSQL(rs("myfield")) 'Return a true/false value baesd on a form submission. 'cwBoolSQL(Request.Form("myCheckBox")) '--------------------------------------------------------------------- Dim sqlTrue, sqlFalse Select Case LCase(dbType) Case "access" sqlTrue = "True" sqlFalse = "False" Case "sql" sqlTrue = 1 sqlFalse = 0 End Select cwBoolSQL = sqlFalse If CBool(str) = True Then cwBoolSQL = sqlTrue End Function 'cwCleanString Function cwOpenQuery(strSQL, strConn) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwOpenQuery 'DESCRIPTION: This function executes a SELECT statement against your ' database and returns a recordset object. 'ARGUMENTS 'strSQL: The strSQL argument contains the entire SELECT statement to be ' run against the database. It should be properly formatted and be a ' completely valid SQL statement, or a standard VBScript recordset error ' will be returned. 'strConn: The strConn argument contains the connection string to be used ' to connect to your database. By default, Cartweaver uses the datasource ' variable, which is defined in CWIncGlobalSettings, and uses the ' connection string in the Connections folder. 'RETURNS 'A recordset object based on the supplied SQL statement. 'EXAMPLES 'Return a query from the default Cartweaver datasource. 'Set rsMyRecordset = CWOpenQuery("SELECT * FROM table", datasource) 'Return a query from a custom datasource. 'Set rsMyRecordset = CWOpenQuery("SELECT * FROM table", "DSN = MyDSN") '--------------------------------------------------------------------- 'Uncomment to next line to output every SQL to the page as it's called. 'Response.Write(strSQL & "
") Set cwOpenQuery = Server.CreateObject("ADODB.Recordset") With cwOpenQuery .ActiveConnection = strConn .Source = strSQL .CursorType = 3 .CursorLocation = 2 .LockType = 1 .Open() End With End Function 'cwOpenQuery Function cwExecuteQuery(strSQL, strConn, strReturnID) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwExecuteQuery 'DESCRIPTION: This function executes an INSERT, UPDATE, or DELETE ' statement against your database. If desired, the function can return ' the ID for a newly inserted record. 'ARGUMENTS 'strSQL: The strSQL argument contains the entire SQL statement to be run ' against the database. It should be properly formatted and be a ' completely valid SQL statement, or a standard VBScript recordset ' error will be returned. If an ID is being returned, it must be a ' specially formatted string of pipe separated values. See the examples ' section for more information on the necessary format. 'strConn: The strConn argument contains the connection string to be used ' to connect to your database. By default, Cartweaver uses the datasource ' variable, which is defined in CWIncGlobalSettings, and uses the ' connection string in the Connections folder. 'strReturnID: This argument is only used when performing an insert and ' returning the newly created ID. If you don’t want a value returned, ' simple pass the value Null. This argument should contain a comma ' separated list containing the table name and the primary key ID field. 'RETURNS 'If an ID is to be returned, the function returns the new ID. There are 'no returns for standard INSERTs, UPDATEs, or DELETEs. 'EXAMPLES 'Execute an INSERT statement against a database. 'Call cwExecuteQuery("INSERT INTO table (field1, field2) VALUES ('value1', value2)", datasource, Null) 'Execute a DELETE statement against a database. 'Call cwExecuteQuery("DELETE FROM table WHERE id = " & myID & ";", datasource, Null) 'Execute an INSERT and return the ID of the newly inserted record. 'Call cwExecuteQuery("fieldname1||value1||fieldname2||text value2", datasource, "table,idfield") '--------------------------------------------------------------------- 'If we want an ID returned If NOT IsNull(strReturnID) Then 'We want an ID returned, so it's assumed that we're doing an insert. Dim arIDData : arIDData = Split(strReturnID,",") Dim x, rsInsert Set rsInsert = Server.CreateObject("ADODB.Recordset") With rsInsert .ActiveConnection = strConn .CursorType = 1 .LockType = 3 .Source = arIDData(0) .Open .AddNew End With Dim arInserts : arInserts = Split(strSQL,"||") For x = 0 To UBound(arInserts) Step 2 rsInsert(arInserts(x)) = arInserts(x + 1) Next rsInsert.Update cwExecuteQuery = rsInsert(arIDData(1)) cwCloseRecordset(rsInsert) Else 'We don't want an ID, so just run the command. 'Response.Write(strSQL & "
") Dim cmdExecute : Set cmdExecute = Server.CreateObject("ADODB.Command") With cmdExecute .ActiveConnection = datasource .CommandText = strSQL .Execute() .ActiveConnection.Close End With Set cmdExecute = Nothing End If 'NOT IsNull(strReturnID) End Function 'cwExecuteQuery Sub cwCloseRecordset(rs) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwCloseRecordset 'DESCRIPTION: Use this function to properly close a recordset. The ' function executes the close method of the recordset object and then ' destroys the object only if the current object exists. 'ARGUMENTS 'rs: The recordset object to close. This is not a string value, but ' the actual recordset object. 'RETURNS 'No return values. 'EXAMPLES 'Close a recordset named myRecordset. 'cwCloseRecordset(myRecordset) '--------------------------------------------------------------------- If IsObject(rs) Then rs.Close() : Set rs = Nothing End Sub 'cwCloseRecordset Function cwMakeSQLDate(strDate,bolTime) '--------------------------------------------------------------------- 'Created: October 1, 2004 'Modified: October 1, 2004 'FUNCTION: cwMakeSQLDate 'DESCRIPTION: Use this function to create a date string to be used in ' Cartweaver in SQL queries. Access and SQL have different delimeter ' requirements. The delimeter used is determined by the dbType ' variable declared in Application.asp 'ARGUMENTS 'strDate: A string containing the date that should be surrounded by the ' proper delimeters. 'bolTime: True or False. Determines if the 24 hour time is appended to ' the date string. Pass False to return just the date. 'RETURNS 'A date string surrounded by either # or ' depending on the dbType ' specified in Application.asp. 'EXAMPLES 'Return a date without a time. 'cwMakeSQLDate(Now(),False) 'Return a date with the time 'cwMakeSQLDate(Request.Form("mydatevar"), True) '--------------------------------------------------------------------- Dim oldLCID : oldLCID = Session.LCID 'Set the locale to US for date insertion purposes Session.LCID = 2057 If IsDate(strDate) Then strDate = CDate(strDate) cwMakeSQLDate = DatePart("d", strDate) & " " & MonthName(DatePart("m", strDate)) & " " & DatePart("yyyy", strDate) If bolTime Then cwMakeSQLDate = cwMakeSQLDate & " " & Hour(strDate) &_ ":" & Minute(strDate) &_ ":" & Second(strDate) End If End If 'Convert the date object into a string to be sure it's no longer manipulated. cwMakeSQLDate = CStr(cwMakeSQLDate) 'Reset the locale Session.LCID = oldLCID Select Case LCase(dbtype) Case "access" cwMakeSQLDate = "#" & cwMakeSQLDate & "#" Case "sql" cwMakeSQLDate = "'" & cwMakeSQLDate & "'" Case Else cwMakeSQLDate = "'" & cwMakeSQLDate & "'" End Select End Function Function cwSqlParam(strTestValue, strDefaultValue, strType) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwSqlParam 'DESCRIPTION: Used in SQL statements to test for the proper data type, ' set default values for INSERTs and UPDATEs when an empty value is ' supplied, and also replace single quotes to prevent SQL injection. ' String data types are surrounded with single quotes to remove the need ' for managing single quotes in complex SQL statements. 'ARGUMENTS 'strTestValue: The value to test for Null values or empty strings. This ' will usually be either a form value provided by user input or a ' querystring value provided by the application. 'strDefaultValue: The value to return if the strTestValue tests true for ' either an empty string or Null. 'strType: The type of value being tested for. Value values are string, ' numeric or date. If a string or date value is chosen, single quotes ' are added around the return value before it’s passed back to the ' application. Both numeric and date values are converted to their ' proper data type to ensure they’re correct. 'RETURNS 'Returns a cleaned string value of the proper data type. 'EXAMPLES 'Clean a value and ensure it has a default value before inserting it ' into the database. 'cwExecuteQuery("INSERT INTO table (field) VALUES (" &_ ' cwSqlParam(Request.Form("myNumber"),0,"numeric") &_ ' ");", datasource, Null) '--------------------------------------------------------------------- cwSqlParam = cwCleanString(cwParam(strTestValue,strDefaultValue)) Select Case strType Case "string" If cwSqlParam <> "Null" Then cwSqlParam = "'" & cwSqlParam & "'" Case "numeric" cwSqlParam = Replace(cwSqlParam, ",", ".") If NOT IsNumeric(cwSqlParam) Then cwSqlParam = 0 cwSQLParam = CStr(cwSQLParam) Case "date" cwSqlParam = CDate(cwSqlParam) If cwSqlParam <> "Null" Then cwSqlParam = "'" & cwSqlParam & "'" End Select End Function 'cwSqlParam '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 'Miscellaneous Functions 'The following functions handle various processing pieces throughout 'Cartweaver '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Function cwCartLinks(intCartQuantity, strReturnURL) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwCartLinks 'DESCRIPTION: Provides links to Cart and Checkout pages. This function ' checks to see if there is a valid user’s cart. If there is a valid ' cart it displays the View Cart and Checkout links along with the ' number of items in the cart. The Cart Links function can be placed ' on any page in your site. 'ARGUMENTS 'intCartQuantity: The intCartQuantity argument should contain the number ' of items currently in the user’s cart. This can be passed using the ' getCount method of the cwObjCartweaver Object (see the Objects ' section in this chapter for more information). 'strReturnURL (Optional): The returnurl variable is the page that will ' be used for the Continue Shopping link on your View Cart target page. ' If a Null value is provided the current URL with querystring values ' is used. 'RETURNS 'A string containing the Cart Links code. 'EXAMPLES 'Return the user to the current page with the querystring intact. 'Response.Write(cwCartLinks(cwCart.getCount(), Null)) 'Return the user to a specific page. 'Response.Write(cwCartLinks(cwCart.Count, "mypage.asp")) '--------------------------------------------------------------------- cwCartLinks = "You have " & intCartQuantity & " item" 'If no return URL was supplied, use the current page If IsNull(strReturnURL) Then strReturnURL = Server.URLEncode(cwGetFullReturnURL(ThisPageQS)) If (intCartQuantity > 1) OR (intCartQuantity = 0) Then cwCartLinks = cwCartLinks & "s" cwCartLinks = cwCartLinks & " in your cart. View Cart | Go to Checkout" If cwDebug Then cwCartLinks = cwCartLinks & " | Turn Debugger " & Session("debugStatus") & "" End Function 'cwCartLinks Function cwValidateEmail(str) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwValidateEmail 'DESCRIPTION: Use this function to determine if a string is a valid ' email address. The function returns True or False depending on the ' result of the test. 'ARGUMENTS 'str: The string to test as a valid email. 'RETURNS 'True or False. 'EXAMPLES 'Execute a block of code if the user does not supply a valid email. 'If NOT cwValidateEmail(Request.Form("myFormVar")) Then '--------------------------------------------------------------------- cwValidateEmail = false Dim regEx, retVal Set regEx = New RegExp 'Create regular expression regEx.Pattern = "^[a-z0-9][\!-\~]*\@[a-z\d\-\.]+\.[a-z]{2,4}(\.[a-z]{2})?$" 'Set pattern regEx.IgnoreCase = true 'Set case sensitivity. retVal = regEx.Test(str) 'Execute the search test. If NOT retVal Then Exit Function cwValidateEmail = true End Function 'cwValidateEmail Function cwIsEmpty(str) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwIsEmpty 'DESCRIPTION: This function tests a string to determine if it's either ' Null, or an empty string and returns True or False based on the result. 'ARGUMENTS 'str: The string to test. 'RETURNS 'True or False. 'EXAMPLES 'Perform an action if the user submitted value is empty. 'If cwIsEmpty(Request.Form("myFormValue") Then '--------------------------------------------------------------------- cwIsEmpty = False If str = "" OR IsNull(str) Then cwIsEmpty = True End Function 'cwIsEmpty Function cwGetImage(intProductID, strType) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwGetImage 'DESCRIPTION: Given a product ID and a file type, this function returns ' the name of a product’s full-size or thumbnail image if it exists. 'ARGUMENTS 'intProductID: The numeric ID of the product you want to return an ' image name for. 'strType: Either "Full" or "Thumb", this determines which type of ' image to return from the database. 'RETURNS 'A string containing the name of the image from the Cartweaver database. 'EXAMPLES 'Return the full-size image for a product. 'ImageSRC = cwGetImage(rsCWGetProduct("product_ID"),"Full") 'Return the full-size image for a product. 'ImageSRC = cwGetImage(rsCWGetProduct("product_ID"),"Thumb") '--------------------------------------------------------------------- Select Case Lcase(strType) Case "thumb" strType = 1 Case "full" strType = 2 Case Else strType = 0 End Select 'Open a query Dim strSQL strSQL = "SELECT tbl_prdtimages.prdctImage_FileName " &_ "FROM tbl_prdtimages " &_ "WHERE tbl_prdtimages.prdctImage_ProductID = " & intProductID & " " &_ "AND tbl_prdtimages.prdctImage_ImgTypeID = " & strType Dim rs Set rs = CWOpenQuery(strSQL,datasource) If rs.RecordCount = 1 Then cwGetImage = rs("prdctImage_FileName") Else cwGetImage = "" End If cwCloseRecordset(rs) End Function 'cwGetImage Function cwKeepURL(strStripValues) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwKeepURL 'DESCRIPTION: This function returns a querystring with the URL values ' passed to the function stripped from the querystring. Use this to ' maintain querystring values through paging, while removing those ' values responsible for the paging itself. 'ARGUMENTS 'strStripValues: A comma separated string containing the names of all ' values that should be removed from the querystring. 'RETURNS 'A string with the supplied values removed from the querystring. 'EXAMPLES 'Strip the querystring value myurl from the current querystring and ' redirect the user. 'Response.Redirect("mypage.asp?" & cwKeepURL("myurl") '--------------------------------------------------------------------- Dim i, qsItem Dim arStripValues : arStripValues = Split(strStripValues,",") If UBound(arStripValues) >= 0 Then For i = 0 To UBound(arStripValues) strStripValues = strStripValues & "&" & arStripValues(i) & "=" Next End If For Each qsItem in Request.Querystring If InStr(strStripValues, "&" & Replace(qsItem, "&", "") & "=") = 0 Then cwKeepURL = cwKeepURL & "&" & Replace(qsItem, "&", "") & "=" & Server.URLEncode(Request.QueryString(qsItem)) Next If Len(cwKeepURL) > 1 Then cwKeepURL = Mid(cwKeepURL, 2) End Function 'cwKeepURL Function cwAltRow(intRow) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwAltRow 'DESCRIPTION: Returns the class for either an odd or even row in a ' table based on the integer passed to the function. 'ARGUMENTS 'intRow: A number representing the current row in a table. 'RETURNS 'A string with either altRowOdd or altRowEven based on whether the ' current row is odd or even-numbered. 'EXAMPLES 'Change the color of a row inside a repeated region with the variable ' i used to count the records. 'Response.Write("") '--------------------------------------------------------------------- cwAltRow = "altRowOdd" If intRow MOD 2 Then cwAltRow = "altRowEven" End Function 'cwAltRow Function cwFileExists(strFullPath) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwFileExists 'DESCRIPTION: This function checks for the existence of an image on ' the server's hard drive. You must pass the full drive path to the ' image to the function. This function is used in conjunction with ' cwGetImage to determine if a product’s image exists. 'ARGUMENTS 'strFullPath: The full path to the image on the server's hard drive, ' including the actual drive declaration, i.e. c:\myfolder\myimage.jpg. 'RETURNS 'True or False. 'EXAMPLES 'Only write an image tag if the file actually exists on the server. 'If cwFileExists("c:\myfile.jpg") = True Then Response.Write("") '--------------------------------------------------------------------- cwFileExists = False Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(strFullPath) Then cwFileExists = True Set objFSO = Nothing End Function 'cwFileExists Function cwCeiling(intNumber) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwCeiling 'DESCRIPTION: Determines the closest integer that is greater than a ' specified number. This function is used to convert decimal numbers ' (such as 2.3) to an integer (3) for use in paging. 'ARGUMENTS 'intNumber: The number to test. 'RETURNS 'The closest whole integer larger than the passed value. 'EXAMPLES 'The following two examples would both return the number 3. 'myCeiling = cwCeiling("2.2") 'myCeiling = cwCeiling("2.9") 'The following two examples would both return the number -2. 'myCeiling = cwCeiling("-2.2") 'myCeiling = cwCeiling("-2.9") '--------------------------------------------------------------------- cwCeiling = Fix(intNumber) If intNumber - cwCeiling <> 0 Then cwCeiling = cwCeiling + 1 End Function 'cwCeiling Function cwMin(int1,int2) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwMin 'DESCRIPTION: This function returns the lesser of two passed values. 'ARGUMENTS 'int1: The first number for testing. 'int2: The second number for testing. 'RETURNS 'The lesser of the two argument’s values. 'EXAMPLES 'The following two examples would both return the value 1. 'myValue = cwMin("1", "2") 'myValue = cwMin("2", "1") '--------------------------------------------------------------------- int1 = CInt(int1) int2 = CInt(int2) cwMin = int1 If int1 > int2 Then cwMin = int2 End Function 'cwMin Function cwMax(int1,int2) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwMax 'DESCRIPTION: This function returns the greater of two passed values. 'ARGUMENTS 'int1: The first number for testing. 'int2: The second number for testing. 'RETURNS 'The greater of the two argument’s values. 'EXAMPLES 'The following two examples would both return the value 2. 'myValue = cwMax("1", "2") 'myValue = cwMax("2", "1") '--------------------------------------------------------------------- int1 = CInt(int1) int2 = CInt(int2) cwMax = int1 If int1 < int2 Then cwMax = int2 End Function 'cwMax Function cwRandomCode(intLength) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwRandomCode 'DESCRIPTION: Returns a random string of the specified length. Due to ' the inherit difficulty in providing true random numbers through ' VBScript, a time code in the format hhmmss is added to the end of ' each generated code to ensure it’s uniqueness. So if a code length ' of 4 is specified, and the time is 3:09:34pm, then the random code ' would be xxxx030934. 'ARGUMENTS 'intLength: Number specifying the length of the desired code. A total ' of six characters are added to the end of the code length to contain ' the time stamp. With this adjustment, the effective length of any ' random code will be intLength + 6. 'RETURNS 'A string containing the random code. 'EXAMPLES 'Return a random code 10 characters long. 'myCode = cwRandomCode(4) 'Return a random code 15 characters long. 'myCode = cwRandomCode(9) '--------------------------------------------------------------------- Dim arCode, strCode 'Array of characters being used for the random code arCode = Array("A","B","C","D","E","F","G","H","I","J","K","L", _ "M","N","O","P","Q","R","S","T","U","V","W","X", _ "Y","Z","1","2","3","4","5","6","7","8","9") 'Generates one random character until it reaches code length For x = 1 TO intLength Randomize strCode = strCode & arCode(Int((UBound(arCode) * Rnd) + 1)) Next cwRandomCode = Right("0" & DatePart("h",Now()),2) & Right("0" & DatePart("m",Now()),2) & Right("0" & DatePart("s",Now()),2) & strCode End Function 'cwRandomCode Function cwParam(strTestValue,strDefaultValue) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwParam 'DESCRIPTION: This function checks to see if the test value is blank ' or Null, and if so, returns the specified default value. 'ARGUMENTS 'strTestValue: Value to test for an empty string or Null. 'strDefaultValue: Value to return if test on testValue is True. 'RETURNS 'A string returning either testValue or defaultValue depending on the ' result of the test. 'EXAMPLES 'Return the value 0 if the user supplied form submission is empty. 'cstExprMonth = cwParam(Request.Form("cstExprMonth"),0) '--------------------------------------------------------------------- cwParam = strTestValue If cwIsEmpty(cwParam) Then cwParam = strDefaultValue End Function 'cwParam Function cwListFind(strList,strSearch) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwListFind 'DESCRIPTION: Returns the index of a found item in a comma separated ' list or array. If no match is found in the list, then -1 is returned. ' The returned integer is a 0-based index. 'ARGUMENTS 'strList: Either an array or a comma separated list of values to test. 'strSearch: String to search for in the array or list. 'RETURNS 'An integer representing the index of the search value in the list or ' array. If the value is not found, then -1 is returned. The returned ' integer is a 0-based index. 'EXAMPLES 'The following example would return the number 2. 'cwListFind("value1,value2,value3", "value3") 'The following example would return the number -1. 'cwListFind("value1,value2,value3", "somevalue") 'The following example would return the number 0. 'cwListFind("value1,value2,value3", "value1") '--------------------------------------------------------------------- Dim i If NOT IsArray(strList) Then strList = Split(Replace(strList,", ",","),",") If IsArray(strList) Then For i = 0 to UBound(strList) If CStr(strList(i)) = CStr(strSearch) Then cwListFind = i Exit Function End If Next Else cwListFind = -1 End If cwListFind = -1 End Function 'cwListFind Sub cwSetError(byRef errorVar,strErr) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwSetError 'DESCRIPTION: This function sets an error item in an error object ' (array). The function getError is then used to check for the existence ' of an error in the same error object. 'ARGUMENTS 'errorVar: The error array to add an error to. This array should ' already exist in the calling page. 'strErr: The name of the error to add to the array. This value ' can be any valid string. The matching string would be used with ' the getError function to determine if there is an associated error. 'RETURNS 'No return values. 'EXAMPLES 'Set an error named errMyField in the myErr object if the user hasn’t ' provided a valid value for the field. 'If Request.Form("MyField") = "" Then Call setError(myErr,"errMyField") '--------------------------------------------------------------------- If NOT IsArray(errorVar) Then ReDim errorVar(0) errorVar(0) = strErr Else ReDim Preserve errorVar(UBound(errorVar)+1) errorVar(UBound(errorVar)) = strErr End If End Sub 'cwSetError Function cwGetError(errorVar,strErr) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwGetError 'DESCRIPTION: Checks for the existence of an error item in an error ' object (array). The function cwSetError is used to add an error to ' the error object. The function returns True if an error matching ' the supplied string exists. 'ARGUMENTS 'errorVar: The error array to check against. This array should already ' exist in the calling page. 'strErr: The name of the error to search for. This value can be any ' valid string. This would be a value that was added to the error ' array using the cwSetError function. 'RETURNS 'True or False based on whether the error exists. 'EXAMPLES 'If the error errMyField exists in the myErr object then perform an action. 'If cwGetError(myErr,"errMyField") Then '--------------------------------------------------------------------- Dim x cwGetError = False If IsArray(errorVar) Then For x = 0 to UBound(errorVar) If LCase(errorVar(x)) = LCase(strErr) Then cwGetError = True Exit Function End If Next End If End Function 'cwGetError Function cwSetFieldLabel(errorObject,strLabel,errorString) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwSetFieldLabel 'DESCRIPTION: This function returns a string with an error message ' wrapped around it if there is an error in the specified error ' object. The cwGetError function is used to determine if an error exists. 'ARGUMENTS 'errorObject: The error array to check against. 'strLabel: The label to be output, with or without the . 'errorString: The name of the error to check for. 'RETURNS 'The label string, with or without the error span depending on the result ' of the cwGetError check. 'EXAMPLES 'Output a label for a text field in the order form. '<%= cwSetFieldLabel(fieldInvalid, "First Name", "cstFirstName") % > '--------------------------------------------------------------------- If cwGetError(errorObject,errorString) Then cwSetFieldLabel = "" & strLabel & "" Else cwSetFieldLabel = strLabel End If End Function 'cwSetFieldLabel Function cwValueList(rs,strFieldName) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwValueList 'DESCRIPTION: This function returns a comma separated string with all ' of the values in the field of the specified recordset. This string ' can then be used along with the cwListFind function to check for ' matching values across recordsets. 'ARGUMENTS 'rs: The recordset to pull values from. 'strFieldName: The field to return from the specified recordset. 'RETURNS 'A comma separated list of values from rs("fieldname"). 'EXAMPLES 'Get a list of all SKU IDs from an recordst named rsGetSKUS. 'Dim SKUList : SKUList = cwValueList(rsGetSKUS,"SKU_ID") '--------------------------------------------------------------------- If NOT IsObject(rs) Then cwValueList = "Invalid recordset " & rs & " passed to cwValueList." Else If rs.RecordCount = 0 Then cwValueList = "" : Exit Function Dim ar, cols, rows, i, returnCol, objField, str ar = rs.GetRows() cols = UBound(ar,1) rows = UBound(ar,2) i = 0 returnCol = 0 For Each objField in rs.Fields If CStr(objField.Name) = CStr(strFieldName) Then returnCol = i Exit For End If i = i + 1 Next For i = 0 To rows str = str & "," & ar(returnCol,i) Next cwValueList = Mid(str,2) rs.MoveFirst() End If End Function 'cwValueList Function cwSetXMLDocument() '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwSetXMLDocument 'DESCRIPTION: This function creates an XML object. This is most often ' used in payment gateways that use form posts to process payments. ' The function attempts to create an XML object using the following ' XML components in the order specified: ' * ServerXMLHTTP.4.0 ' * ServerXMLHTTP.3.0 ' * ServerXMLHTTP 'If no object can be created, an error is returned. 'ARGUMENTS 'No arguments. 'RETURNS 'If a valid object is created, an XML object is returned. If there is ' an error, than a string detailing the error is returned. 'EXAMPLES 'Create an XML object and post a transaction to a URL. 'Dim objHTTP 'Set objHttp = cwSetXMLDocument 'objHttp.open "POST", "https://www.somesite.com/ ", false 'objHttp.Send postString '--------------------------------------------------------------------- On Error Resume Next Err = 0 'Array of possible XML components Dim xmlComs, i, xmlObj xmlComs = Array("WinHTTP.WinHTTPRequest.5.1","Msxml2.ServerXMLHTTP.4.0","Msxml2.ServerXMLHTTP.3.0","MSXML2.ServerXMLHTTP") 'Loop through all possible XML components For i = 0 to UBound(xmlComs) set xmlObj = Server.CreateObject(xmlComs(i)) 'If the xml component is installed, exit the function If IsObject(xmlObj) Then Set cwSetXMLDocument = xmlObj On Error Goto 0 Exit Function Else Err.Clear End If Next cwSetXMLDocument = "Error: Your server does not have a valid MSXML ServerXMLHTTP Component installed." On Error Goto 0 End Function 'cwSetXMLDocument Function cwBuildMultiArray(str,strGroupSeparator,strValueSeparator) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwBuildMultiArray 'DESCRIPTION: This function converts a string into a multi-dimensional ' array. This can be useful for turning a querystring ' ("var1=val1&var2=val2&var3=val3") into a 2-dimensional array for ' looping through values. 'ARGUMENTS 'str: The string to convert into a multi-dimensional array. 'strGroupSeparator: Separator for each variable/value pair. In a ' querystring this would be "&". 'strValueSeparator: Separator for each value. In a querystring this would ' be "=". 'RETURNS 'A 2-dimensional array based on the values passed through the str argument. 'EXAMPLES 'Split the current querystring into a 2-dimensional array. 'myArray = cwBuildMultiArray(Request.Querystring,"&","=") '--------------------------------------------------------------------- Dim myArray, x, y, tempArray myArray = Split(str,strGroupSeparator) For x = 0 to UBound(myArray) myArray(x) = Split(myArray(x),strValueSeparator) Next For x = 0 to UBound(myArray) For y = 0 to UBound(myArray(x)) tempArray = myArray(x) Next Next ReDim newArray(UBound(myArray),UBound(myArray(0))) For x = 0 to UBound(newArray,1) For y = 0 to UBound(newArray,2) tempArray = myArray(x) newArray(x,y) = tempArray(y) Next Next cwBuildMultiArray = newArray End Function 'cwBuildMultiArray '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 'Debugging Functions 'These functions provide debug output for the Cartweaver application '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Function cwDebugger(str) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwDebugger 'DESCRIPTION: Adds the passed in string to strDebugOutput, the global ' variable used to store accumulated debug output, and then adds a ' line break directly after the string. If cwDebug is set to False ' in Application.asp, no action is taken to reduce load on live sites. 'ARGUMENTS 'str: The string to add to the end of strDebugOutput. 'RETURNS 'No return values. 'EXAMPLES 'Add a string to the debug output. 'cwDebugger("Some debug information: " & someVar) '--------------------------------------------------------------------- If CBool(Session("debug")) Then strDebugOutput = strDebugOutput & str & "
" End If End Function 'cwDebugger Function cwQueryDump(rs,strLabel) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwQueryDump 'DESCRIPTION: This function is used to output the entire contents of ' a recordset for debugging purposes. The output includes the ' RecordCount and SQL for the recordset. If cwDebug in Application.asp ' is set to False then no action is taken to reduce load on live sites. 'ARGUMENTS 'rs: The recordset object to dump. 'strLabel: The label to use for the query dump table. This is used as ' the in the output table. 'RETURNS 'If the recordset is empty, a string stating such is returned, ' otherwise a table containing all of the records in the recordset is ' returned. 'EXAMPLES 'Dump a recordset named myRS with a caption of myRS. 'cwQueryDump(myRecordset, "myRecordset") '--------------------------------------------------------------------- If NOT CBool(Session("debug")) Then Exit Function If IsObject(rs) Then If NOT rs.EOF Then 'Outputs a query, it's source, and all returned records. Dim objField, intNumFields, str, x intNumFields = rs.Fields.Count str = str & "" &_ "" &_ "" For Each objField in rs.Fields str = str & "" Next 'objField in rs.Fields str = str & "" Do While NOT rs.EOF str = str & "" For Each objField in rs.Fields str = str & "" Next 'objField in rs.Fields str = str & "" rs.MoveNext() Loop 'While NOT rs.EOF str = str & "
" & strLabel & "
SQL: " & rs.source & "
Records: " & rs.RecordCount & "
" & objField.Name & " - " & cwGetFieldType(objField.Type,False) & "
" If objField.Type = 136 Then str = str & cwQueryDump(objField.Value,"Child Recordset (datashaping)") Else str = str & objField.Value End If str = str & " 
" rs.MoveFirst() Else str = "" & strLabel & " is empty:
" & rs.Source End If 'IsObject(recordset) cwQueryDump = str Else cwQueryDump = "You must pass a valid recordset object to the cwQueryDump function." End If End Function 'cwQueryDump Function cwGetFieldType(str,bolDescrip) '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwGetFieldType 'DESCRIPTION: Returns a friendly type name based on the type value for ' a recordset field. 'ARGUMENTS 'str: This argument should contain a string with the numeric data type ' code from a recordset field. This can be obtained by using ' myRS("myField").Type. 'bolDescrip: True or False. Determines whether the description for the ' type is also returned. 'RETURNS 'A string containing the type name of the current field, and the ' description of the field if desired. 'EXAMPLES 'Display the type for the field myField in the recordset myRS. 'Response.Write(cwGetFieldType(myRS("myField").Type)) '--------------------------------------------------------------------- Dim arTypes arTypes = "AdArray|0x2000|A flag value, always combined with another data type constant, that indicates an array of that other data type." &_ "|adBigInt|20|Indicates an eight-byte signed integer (DBTYPE_I8)." &_ "|adBinary|128|Indicates a binary value (DBTYPE_BYTES)." &_ "|adBoolean|11|Indicates a boolean value (DBTYPE_BOOL)." &_ "|adBSTR|8|Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR)." &_ "|adChapter|136|Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER)." &_ "|adChar|129|Indicates a string value (DBTYPE_STR)." &_ "|adCurrency|6|Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000." &_ "|adDate|7|Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day." &_ "|adDBDate|133|Indicates a date value (yyyymmdd) (DBTYPE_DBDATE)." &_ "|adDBTime|134|Indicates a time value (hhmmss) (DBTYPE_DBTIME)." &_ "|adDBTimeStamp|135|Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP)." &_ "|adDecimal|14|Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL)." &_ "|adDouble|5|Indicates a double-precision floating-point value (DBTYPE_R8)." &_ "|adEmpty|0|Specifies no value (DBTYPE_EMPTY)." &_ "|adError|10|Indicates a 32-bit error code (DBTYPE_ERROR)." &_ "|adFileTime|64|Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME)." &_ "|adGUID|72|Indicates a globally unique identifier (GUID) (DBTYPE_GUID)." &_ "|adIDispatch|9|Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH). Note This data type is currently not supported by ADO. Usage may cause unpredictable results." &_ "|adInteger|3|Indicates a four-byte signed integer (DBTYPE_I4)." &_ "|adIUnknown|13|Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN). Note This data type is currently not supported by ADO. Usage may cause unpredictable results." &_ "|adLongVarBinary|205|Indicates a long binary value." &_ "|adLongVarChar|201|Indicates a long string value." &_ "|adLongVarWChar|203|Indicates a long null-terminated Unicode string value." &_ "|adNumeric|131|Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC)." &_ "|adPropVariant|138|Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT)." &_ "|adSingle|4|Indicates a single-precision floating-point value (DBTYPE_R4)." &_ "|adSmallInt|2|Indicates a two-byte signed integer (DBTYPE_I2)." &_ "|adTinyInt|16|Indicates a one-byte signed integer (DBTYPE_I1)." &_ "|adUnsignedBigInt|21|Indicates an eight-byte unsigned integer (DBTYPE_UI8)." &_ "|adUnsignedInt|19|Indicates a four-byte unsigned integer (DBTYPE_UI4)." &_ "|adUnsignedSmallInt|18|Indicates a two-byte unsigned integer (DBTYPE_UI2)." &_ "|adUnsignedTinyInt|17|Indicates a one-byte unsigned integer (DBTYPE_UI1)." &_ "|adUserDefined|132|Indicates a user-defined variable (DBTYPE_UDT)." &_ "|adVarBinary|204|Indicates a binary value." &_ "|adVarChar|200|Indicates a string value." &_ "|adVariant|12|Indicates an Automation Variant (DBTYPE_VARIANT). Note This data type is currently not supported by ADO. Usage may cause unpredictable results." &_ "|adVarNumeric|139|Indicates a numeric value." &_ "|adVarWChar|202|Indicates a null-terminated Unicode character string." &_ "|adWChar|130|Indicates a null-terminated Unicode character string (DBTYPE_WSTR)." arTypes = Split(arTypes,"|") Dim i For i = 0 To UBound(arTypes) STEP 3 If CStr(str) = CStr(arTypes(i+1)) Then If bolDescrip Then cwGetFieldType = arTypes(i) & " (" & arTypes(i+2) & ")" Else cwGetFieldType = arTypes(i) End If Exit Function End If Next End Function Function cwDebugOutput() '--------------------------------------------------------------------- 'Created: July 25, 2004 'Modified: July 25, 2004 'FUNCTION: cwDebugOutput 'DESCRIPTION: Outputs scope variables for the application, as well as ' any debug output collected in strDebugOutput through the cwDebugger ' function. If cwDebug is set to False in Application.asp, no action ' is taken to reduce load on live sites. 'ARGUMENTS 'No arguments. 'RETURNS 'A string containing all of the debug information collected on the current page. 'EXAMPLES: 'Output all of the collected debug output. ' Response.Write(cwDebugOutput) '--------------------------------------------------------------------- 'Outputs debut strings. Turn on and off with the cwDebug option in Application.asp If CBool(Session("debug")) Then cwDebugOutput = "" cwDebugOutput = cwDebugOutput & "

Cartweaver Debugger

" cwDebugOutput = cwDebugOutput & strDebugOutput cwDebugOutput = cwDebugOutput & "Page execution time: " & Timer - TickCount & " s" 'Output all built-in Cartweaver variables cwDebugOutput = cwDebugOutput & "

Built-in Cartweaver Variables

    " Dim arVarList, strVarList arVarList = "websiteURL,websiteSSLURL,onSubmitAction,targetResults,recordsAtATime,targetDetails," &_ "detailsDisplay,targetGoToCart,targetCheckout,targetConfirmOrder,cwLocale,uploadCom,mailObj," &_ "mailServer,paymentAuthType,paymentAuthName,enableErrorHandling,cwDebug," &_ "dbType,ThisPage,ThisPageQS,ImageThumbFolder,ImageLargeFolder" arVarList = Split(arVarList,",") Dim i For i = 0 to UBound(arVarList) Execute("cwDebugOutput = cwDebugOutput & ""
  • " & arVarList(i) & ": "" & " & arVarList(i) & " & ""
  • """) Next cwDebugOutput = cwDebugOutput & "
" 'Output all VBScript collections Dim collectionItem Dim arCollections : arCollections = Array("Application.Contents","Session.Contents","Request.Form","Request.Querystring","Request.Cookies","Request.ServerVariables") For i = 0 to UBound(arCollections) cwDebugOutput = cwDebugOutput & ("

" & arCollections(i) & "

    ") Execute("For Each collectionItem in " & arCollections(i) & ":cwDebugOutput = cwDebugOutput & ""
  • "" & collectionItem & "": "" & " & arCollections(i) & "(collectionItem) & ""
  • "":Next") cwDebugOutput = cwDebugOutput & ("
") Next cwDebugOutput = cwDebugOutput & "
" cwDebugOutput = cwDebugOutput & "" End If End Function 'cwDebugOutput Function cwGetFullReturnURL(pagePath) '--------------------------------------------------------------------- 'Created: November 19, 2005 'Modified: November 19, 2005 'FUNCTION: cwGetFullReturnURL 'DESCRIPTION: Builds a full HTTP return URL based on the websiteURL ' variable declared in Application.asp and the pagePath passed to the ' function. If no pagePath is passed, then the SCRIPT_NAME for the ' current page will be used. 'ARGUMENTS ' pagePath: The page to build a full HTTP address to. 'RETURNS 'A string containing the full HTTP path of the return url page. 'EXAMPLES: 'Output all of the collected debug output. ' cwGetFullReturnURL(null) ' cwGetFullReturnURL(ThisPageQS) '--------------------------------------------------------------------- If IsNull(pagePath) Then pagePath = Request.ServerVariables("SCRIPT_NAME") 'Get the location of the final / in the pagePath Dim SlashPosition : SlashPosition = InStrRev(pagePath, "/") If SlashPosition <> 0 Then pagePath = Mid(pagePath, SlashPosition + 1) End If cwGetFullReturnURL = websiteURL & pagePath End Function %> <% '================================================================ 'Application Info: ' Cartweaver© 2002 - 2005, All Rights Reserved. 'Developer Info: ' Application Dynamics Inc. ' 1560 NE 10th ' East Wenatchee, WA 98802 'Support Info: http://www.cartweaver.com/go/asphelp ' 'Cartweaver Version: 2.4 - Date: 11/27/2005 '================================================================ 'Name: Cartweaver Cart Object 'Description: This is the heart of the Cartweaver application. ' When a customer adds, updates or deletes an item in their cart, ' this is the file that does the work. Cartweaver stores the ' actual cart data in tbl_cart in the database and maintains the ' Cart ID in a client cookie (Request.Cookies("CartID")). The ' cookie is set when the object is created if it doesn’t exist. ' The Cartweaver Object can be used on any page in your site. ' It is included in the CWIncDetails.asp and CWIncShowCart.asp ' files by default. 'See each individual property and method for more information on ' their syntax and usage. '================================================================ '*Do Not Remove This Line* Prevents extraneous %@LANGUAGE="VBSCRIPT"% declaration from being added by Dreamweaver. Class cwObjCartweaver 'Store internal result strings. Dim cwResult Dim cwStockAlert Dim cwError Dim cwCartCount Dim cwi Dim qtyRequested Private Sub Class_Initialize() 'Create new cart if it doesn't exist. If Request.QueryString("cart") <> "" Then Response.Cookies("CartID") = Request.QueryString("cart") Response.Cookies("CartID").Expires = Now() + 7 ElseIf Request.Cookies("CartID") = "" Then Response.Cookies("CartID") = Session.SessionID Response.Cookies("CartID").Expires = Now() + 7 End If 'Fill results from querystrings if they exist. If Request.QueryString("result") <> "" Then cwResult = Request.QueryString("result") If Request.QueryString("StockAlert") <> "" Then cwStockAlert = Request.QueryString("StockAlert") End Sub Private Sub Class_Terminate() 'Clean up recordsets involved with cwObjCartweaver. 'Always call Set cwObjCartweaver = Nothing when done. End Sub Public Property Get Count 'This property returns the number of items currently in the user’s cart. 'This property is read-only. Count = getCount() End Property Public Property Get Result 'This property returns the number of items added to the cart with the last call of the Add or Update methods. 'This property is read-only. Result = cwResult End Property Public Property Get CartError 'This property returns any errors generated by the cart actions. 'This property is read-only. CartError = cwError End Property Public Property Get StockAlert 'This property returns True or False if a product is or is not out of stock. 'This property is read-only. If cwStockAlert = "" Then cwStockAlert = False StockAlert = cwStockAlert End Property Public Function Add(SKU,Qty,bolRedirect) 'Add one or more SKUs to the cart as defined by the SKU and Qty ' Arguments. To add multiple SKUs, pass a comma separated list ' of SKUs and quantities. The multiple SKU additions are used on ' CWIncDetails.asp when adding products from a crosstab table of ' SKUs, where multiple SKUs can be added at one time. This method ' has the following arguments: ' * SKU: The SKU argument passes either a specific SKU ID or a ' comma separated list of SKU IDs. The SKU ID passed is the ' SKU_ID field from tbl_skus. If a comma separated list of SKU ' IDs is passed, the Qty argument should contain a matching ' list of quantities. ' * Qty: The Qty argument passes either a single quantity or a ' comma separated list of quantities. If 0 is passed, the SKU is ' deleted from the cart. If a comma separated list of SKU IDs is ' passed, the Qty argument should contain a matching list of ' quantities. ' * bolRedirect: This value should be either True or False, whether ' to redirect based on user preferences. This value should be set ' to False while running through a list of SKUs. Dim skuList : skuList = makeNumericArray(SKU) Dim qtyList : qtyList = makeNumericArray(Qty) 'If we have an array of products, add each one. If IsArray(skuList) Then qtyRequested = 0 For cwi = 0 to UBound(skuList) If cwi = UBound(skuList) Then 'If this is the last one, add, and redirect. Add skuList(cwi), qtyList(cwi), True Else 'We still have skus, so don't redirect quite yet. Add skuList(cwi), qtyList(cwi), False End If 'cwi = UBound(skuList) Next 'cwi = 0 to UBound(skuList) Exit Function End If 'IsArray(skuList) If NOT IsNumeric(SKU) Then cwError = "The SKU ID must be a numeric value." : Exit Function If NOT IsNumeric(Qty) Then cwError = "Please enter a valid quantity." : Exit Function If Qty = 0 AND cwResult = 0 AND cwStockAlert = False Then cwError = "Please choose a valid quantity." : Exit Function Else cwError = "" End if Qty = Abs(Round(Qty)) qtyRequested = qtyRequested + Qty '======Start all of the add work====== 'Check for items already in the cart, and if it's there, just update it. Dim rsCheckSku Set rsCheckSku = cwOpenQuery("SELECT cart_Line_ID, cart_sku_qty FROM tbl_cart WHERE cart_custcart_ID ='" & Request.Cookies("CartID") & "' AND cart_sku_ID = " & SKU,datasource) cwDebugger "rsCheckSku: " & rsCheckSku.Source cwDebugger "rsCheckSku.EOF: " & rsCheckSku.EOF 'If we've got a match, do the update. If NOT rsCheckSku.EOF Then 'Get number added cwResult = cwResult + (CheckStockCount(SKU,rsCheckSku("cart_sku_qty") + Qty) - rsCheckSku("cart_sku_qty")) cwDebugger "cwObjCartweaver, cwResult for sku " & SKU & ": " & cwResult Call Update(rsCheckSku("cart_Line_ID"), CheckStockCount(SKU,rsCheckSku("cart_sku_qty") + Qty)) cwCloseRecordset(rsCheckSku) If cwResult <> 0 AND CLng(cwResult) = CLng(qtyRequested) Then cwStockAlert = False Else 'QtyAdded = 0 OR QtyAdded <> qtyRequested cwStockAlert = True End If 'QtyAdded <> 0 AND QtyAdded = qtyRequested Exit Function End If 'NOT rsCheckSku.EOF cwCloseRecordset(rsCheckSku) 'If it wasn't an update, then add it. Qty = CheckStockCount(SKU,Qty) cwDebugger "cwObjCartweaver, CheckStockCount for sku " & sku & ": " & Qty If Qty <> 0 Then Call cwExecuteQuery("INSERT INTO tbl_cart (cart_custcart_ID, cart_sku_ID, cart_sku_qty, cart_dateadded) VALUES ('" & Request.Cookies("CartID") & "'," & SKU & "," & Qty & ", " & cwMakeSQLDate(Now(), True) & ");",datasource,Null) cwResult = cwResult + Qty If bolRedirect Then 'If it's time to redirect. If cwResult <> 0 AND CLng(cwResult) = CLng(qtyRequested) Then cwStockAlert = False Else 'QtyAdded = 0 OR QtyAdded <> qtyRequested cwStockAlert = True End If 'QtyAdded <> 0 AND QtyAdded = qtyRequested End If 'bolRedirect End Function 'Add Public Function Update(LineID,QtyNew) 'Update a specific item in the cart to a specific quantity as ' defined by the LineID and QtyNew arguments. Setting the quantity ' to 0 will delete an item from the cart. This method has the ' following arguments: ' * LineID: This argument is the cart_Line_ID from tbl_Cart that ' should be updated. ' * QtyNew: This argument is the new quantity for the specified ' LineID. Dim lineList : lineList = makeNumericArray(LineID) Dim qtyList : qtyList = makeNumericArray(QtyNew) 'If we have an array of products, add each one. If IsArray(lineList) Then For cwi = 0 to UBound(lineList) If qtyList(cwi) <> 0 Then UpdateLineItem lineList(cwi), CheckStockByLineID(lineList(cwi), qtyList(cwi)) Else Delete lineList(cwi) End If 'qtyList(cwi) <> 0 Next 'cwi = 0 to UBound(lineList) Exit Function Else If lineList = -1 Then cwError = "The Line ID must be a numeric value." : Exit Function If qtyList = -1 Then cwError = "The quantity must be a numeric value." : Exit Function If QtyNew <> 0 Then UpdateLineItem LineID, CheckStockByLineID(LineID, QtyNew) Else Delete LineID End If 'QtyNew <> 0 End If 'IsArray(skuList) End Function 'Update Private Function UpdateLineItem(LineID, Qty) Call cwExecuteQuery("UPDATE tbl_cart SET cart_sku_qty = " & Qty & " WHERE cart_line_id = " & LineID & ";",datasource,Null) End Function Public Function Delete(LineID) 'Delete an item from the cart as defined by the LineID ' argument. This method has one argument, LineID, which ' is the cart_Line_ID from tbl_Cart that should be deleted. If LineID = "" Then LineID = 0 Call cwExecuteQuery("DELETE FROM tbl_cart WHERE cart_line_id IN (" & LineID & ");",datasource,Null) End Function 'Delete Public Function MultiOption(options,productID,qty) 'Add a SKU based on the SKU options as defined in the Options ' argument. The appropriate SKU is found for you based on the ' options passed to the object. The CWIncDetails.asp include ' uses this method when adding products with two options. ' This method has the following arguments: ' * Options: This argument should contain a comma separated ' list of option IDs for the product that should be added ' to the cart. This is used along with the Product ID to ' find the correct SKU to add to the cart. ' * ProductID: The numeric Product ID for the product that ' should be added to the cart. This is used along with the ' options list to find the correct SKU to add to the cart. ' * Qty: The quantity of items to add to the cart. Dim arOptions If NOT IsNumeric(options) Then arOptions = makeNumericArray(options) If NOT IsArray(arOptions) Then cwError = "The optionlist must be a numeric group of values" : Exit Function Else arOptions = Split(options,",") End If If NOT IsNumeric(qty) Then cwError = "The quantity must be a numeric group of values" : Exit Function Dim numOptions : numOptions = UBound(arOptions) + 1 Dim optionList, i For i = 0 to UBound(arOptions) optionList = optionList & "," & arOptions(i) Next optionList = Mid(optionList,2) 'Get any found skus. Use optionList to filter the recordset Dim rsSKU, query_rsSKU query_rsSKU = "SELECT tbl_skus.SKU_ID " &_ "FROM tbl_skus " &_ "INNER JOIN tbl_skuoption_rel ON tbl_skus.SKU_ID = tbl_skuoption_rel.optn_rel_SKU_ID " &_ "WHERE tbl_skuoption_rel.optn_rel_Option_ID In (" & optionList & ") " &_ "GROUP BY tbl_skus.SKU_ID, tbl_skus.SKU_ProductID " &_ "HAVING tbl_skus.SKU_ProductID = " & productID & " AND Count(tbl_skuoption_rel.optn_rel_Option_ID) = " & numOptions & ";" Set rsSKU = cwOpenQuery(query_rsSKU,datasource) If NOT rsSKU.EOF Then 'Add the sku to be added to our cart to the end of our array Call Add(rsSKU("SKU_ID"),qty,True) Else cwError = "No product matches the combination of options you have selected." rsSKU.Close() Set rsSKU = Nothing Exit Function End If End Function 'MultiOption Private Function CheckStockByLineID(LineID, QtyRequested) If NOT Application("AllowBackOrders") Then Dim rsStockSKU, newQty Set rsStockSKU = cwOpenQuery("SELECT cart_sku_id FROM tbl_cart WHERE cart_line_ID = " & LineID, datasource) newQty = CheckStockCount(rsStockSKU("cart_sku_id"), QtyRequested) If cwStockAlert = False AND CLng(newQty) <> CLng(QtyRequested) Then cwStockAlert = True End If cwDebugger "CheckStockByLineID: " & newQty & " : " & QtyRequested CheckStockByLineID = newQty Else CheckStockByLineID = QtyRequested End If End Function Public Function CheckStockCount(SKU,QtyRequested) 'This function is used to check if there is enough stock to ' fulfill a user’s quantity request. The function will ' return the total available stock for a product. If backorders ' are allowed, it will simply return the value based through ' the QtyRequested argument. This method has the following ' arguments: ' * SKU: The numeric SKU ID of the item to check against. ' * QtyRequested: The quantity requested by the user. CheckStockCount = QtyRequested If NOT CBool(Application("AllowBackOrders")) Then 'If Backorders are not allowed Check total quantity in the cart to be sure 'that the updated amount will not exceed the stock count. 'If it does, adjust quantity to Stock Count. Dim rsStockCount Set rsStockCount = cwOpenQuery("SELECT SKU_Stock FROM tbl_skus WHERE SKU_ID = " & SKU,datasource) cwDebugger "CheckStockCount stock for sku " & sku & ": " & rsStockCount("sku_stock") cwDebugger "CheckStockCount qty requested for sku " & sku & ": " & QtyRequested 'If the new quantity exceeds the stock quantity If CLng(rsStockCount("sku_stock")) <= 0 Then CheckStockCount = 0 Else If CLng(QtyRequested) > CLng(rsStockCount("sku_stock")) Then CheckStockCount = rsStockCount("sku_stock") End If 'QtyRequested > rsStockCount End If 'rsStockCount("sku_stock") <= 0 cwCloseRecordset(rsStockCount) End If 'NOT Application("AllowBackOrders") End Function 'CheckStockCount Public Function ClearCart() 'This function clears the user’s cart of all contents, sets ' their cart ID to an empty string, and clears their ' Session("CheckingOut") variable. This function has no ' arguments. Call cwExecuteQuery("DELETE FROM tbl_cart WHERE cart_custcart_ID = '" & Request.Cookies("CartID") & "';",datasource,Null) 'Clear all Cart Variables Response.Cookies("CartID") = "" Session("CheckingOut") = "" End Function 'ClearCart Private Function getCount() 'This function returns the number of items in the cart. There are no arguments for this method. Dim rsCartCount Set rsCartCount = cwOpenQuery("SELECT Sum(tbl_cart.cart_sku_qty) AS cartCount " &_ "FROM tbl_cart GROUP BY tbl_cart.cart_custcart_ID " &_ "HAVING tbl_cart.cart_custcart_ID = '" & Request.Cookies("CartID") & "';", datasource) getCount = 0 If NOT rsCartCount.EOF Then getCount = rsCartCount("cartCount") cwCloseRecordset(rsCartCount) End Function 'getCount() Private Function makeNumericArray(str) 'This function takes a comma separated list of numeric values ' and creates an array. If there is only one value passed, ' that single value is returned as a string. If there are any ' non-numeric values, they are converted to a 0. This is used ' to ensure that alpha characters are not passed to the Add ' and Update methods during multiple SKU additions. This ' function has one argument, str, which is a comma separated ' list of values to convert into an array. Dim ar, i ar = Split(str,",") For i = 0 to UBound(ar) 'If the value isn't numeric, make it 0. If NOT IsNumeric(ar(i)) Then ar(i) = 0 Next If UBound(ar) = 0 Then makeNumericArray = ar(0) Else makeNumericArray = ar End If End Function 'makeNumericArray End Class 'cwObjCartweaver %> <% 'Start Cartweaver Cart Set cwCart = New cwObjCartweaver %> <% '============================================================================ 'This is the presentation file for the Home Page. We have placed 'a few example searches to demonstrate how they will look on the page. '============================================================================ %> North Central Washington Digital :: Photographic Excellence <meta name="keywords" content="Wenatchee Photographic Excellence, Wenatchee Photography, North Central Washington Photography, Photos, Prints, Wedding Photography, Senior Portraits, Family Portraits, Product Photography, Sports Photography, Photo Restorations, Web Design, Graphic Design, Computer Consultation, CD Business Cards">

NCW DIGITAL ONLINE STORE

Archives
Please contact us for any photos from these past events:
Phone: 509-670-2808
Email: al@ncwdigital.com

 

2009
2008
2007
Highgate-"No Business After Hours" GWPCP Family Photos 2008 Wenatchee Valley Chamber Golf Tournament 2007
Hippity Hoppity Fun Run GWPCP Class Photos 2008 Fabulous Feet Dance Photos 2007
  Hot August Days 2008
Montessori Daddy Daughter Dance 2007
  Fabulous Feet Dance Stucio Photos 2008 Montessori Children's School
  The Wenatchee World 's JR. Ridge 2 River Relay Race 2008 Greater Wenatchee Parent-Child Preschool Family Portrait Days
  Alcoa's Ridge 2 River Relay Race 2008
Hot August Days 2007
  Wenatchee Valley Du 2008 Cycle Washington Memorial Ride 2007
  Montessori Childrens School Class Photos 2008 Alcoa's Ridge 2 River Relay Race 2007
  Montessori Daddy/Daughter Dance Photos 2008 Greater Wenatchee Parent-Child Preschool Class Photos 2007
    Wenatchee World's Jr. Ridge 2 River Relay 2007
    Wenatchee Valley Duathlon 2007

The galleries below have a few of our most favorite prints available for sale. Please call us if you are looking for a specific print from our extensive photo library.  

<% Set cwSearchObj = New cwSearch With cwSearchObj .SearchType = "Links" .AllCategoriesLabel = "All Products" .Separator = "
" .SelectedStart = "" .SelectedEnd = "" End With Response.Write(cwSearchObj.Display()) Set cwSearchObj = Nothing %>