<% ' ===================================================================================== ' = File: incGoCartCustom.asp ' = File Version: 5.1 (beta) ' = Library Version: GoCart 5b1 (beta) ' = Copyright (c)1997-2000 SacWeb, Inc. All rights reserved. ' = Description: ' = GoCart API Customizations ' = Revision History: ' = 14jul2000 (5.1 beta) ssutterfield: general code cleanup/documentation ' = 01june2004 bkonvalin: changed "US Postal Service" to "US Priority Mail (2-4 day average)" per client ' = Description of Customizations: ' = ' ===================================================================================== ' BLN_SUPPORT_OEC: true if GoCart supports online processing (e.g. ECHO) const BLN_SUPPORT_OEC = false const STR_MERCHANT_NAME = "Grinberg" const STR_MERCHANT_ADDRESS1 = "4120 Douglas Blvd." const STR_MERCHANT_ADDRESS2 = "#306-338" const STR_MERCHANT_CITY = "Granite Bay" const STR_MERCHANT_STATE = "CA" const STR_MERCHANT_ZIP = "95746" const STR_MERCHANT_COUNTRY = "US" const STR_MERCHANT_PHONE = "1-888-745-4431" const STR_MERCHANT_FAX = "" '"(916)444-1234" const STR_MERCHANT_EMAIL = "info@Grinberg.com" const STR_MERCHANT_CS_PHONE = "" '"916-444-1234" const STR_MERCHANT_CS_EMAIL = "info@Grinberg.com" const STR_MERCHANT_COPYRIGHT = "Copyright © 1998 - 2008 Handwritten Thank You Cards. All rights reserved." const STR_MERCHANT_DEFAULT_URL = "main.asp?updateheader=1" const STR_MERCHANT_TRACKING_PREFIX = "EXSWest-" '"TRK-" const SESSION_MERCHANT_UID = "EXSWest_buy_meruid" ' intID of user record of logged-in user const SESSION_MERCHANT_ULOGIN = "EXSWest_buy_merulogin" ' username of logged-in user const SESSION_MERCHANT_UNAME = "EXSWest_buy_meruname" ' full name of logged-in user const SESSION_MERCHANT_UTIME = "EXSWest_buy_merutime" ' login time of logged-in user const SESSION_MERCHANT_ACCESS_STATUS = "EXSWest_buy_meraccstatus" ' specifies what order status's can be seen by this user const SESSION_MERCHANT_ACCESS = "EXSWest_buy_meracc" ' specifies the access flags of the logged-in user const SESSION_MERCHANT_BID = "EXSWest_buy_merbid" ' intBrand of user record of logged-in user const SESSION_REPORT_START = "EXSWest_buy_repstart" ' reporting period start date const SESSION_REPORT_END = "EXSWest_buy_repend" ' reporting period end date const SESSION_EXPORT_SHOPPER = "EXSWest_buy_expshpr" ' flags for including billing or shipping addresses const SESSION_EXPORT_FORMAT = "EXSWest_buy_expformat" ' specifies format of export data const SESSION_REFERAL_ID = "EXSWest_refid" const SESSION_REFERAL_NAME = "EXSWest_refname" const SESSION_REFERAL_DISCOUNT = "EXSWest_refdiscount" const STR_TABLE_INVENTORY = "EXSWest_Inv" const STR_TABLE_SHOPPER = "EXSWest_Shopper" const STR_TABLE_ORDER = "EXSWest_Order" const STR_TABLE_LINEITEM = "EXSWest_LineItem" const STR_TABLE_TRANS = "EXSWest_Trans" const STR_TABLE_USER = "EXSWest_AdminUser" const STR_TABLE_AUDIT = "EXSWest_Audit" const STR_TABLE_REFERER = "EXSWest_Referer" const STR_TABLE_SHIPZONE = "EXSWest_ShipZone" const STR_TABLE_SHIPRATE = "EXSWest_ShipRate" const STR_TABLE_GODOC = "EXSWest_GoDoc" const INT_PACKAGE_WEIGHT = 0.5 '0.5 lbs for box/envelope weight const INT_HANDLING_FEE = 0 'ADD $0 Handling Fee to all orders const INT_UPS_SHIP_CONFIRM_PRICE = 0 'ADD $0 UPS Shipping confirmation fee const INT_UPS_HANDLING_FEE = 2.0 'ADD $2 Handling Fee to all UPS orders dim cGoCart_CartListRowBG, cGoCart_CartListHdrText, cgoCart_InvDivider, cGoCart_CSLoginBG, cGoCart_CSHdrText, cGoCart_CSHdrBG, cGoCart_CSTotalRowBG, cGoCart_CSSelectBG cGoCart_CartListRowBG = cVVLtGrey cGoCart_CartListHdrText = cBlue cGoCart_InvDivider = cGrey cGoCart_CSLoginBG = cVVLtGrey cGoCart_CSHdrText = cBlack cGoCart_CSHdrBG = cGrey cGoCart_CSTotalRowBG = cVVLtGrey cGoCart_CSSelectBG = cVDkGrey dim dctPaymentMethod, dctTaxZoneRates, dctCreditCardTypeValues, dctCountryCodes, dctShipOption, dctUSStateCodes dim dctSubscribe set dctSubscribe = Server.CreateObject("Scripting.Dictionary") dctSubscribe.Add "0", "Art of Papua New Guinea" dctSubscribe.Add "1", "Art of Irian Jaya (W. New Guinea)" dctSubscribe.Add "2", "Other Oceanic Art" dctSubscribe.Add "3", "Art of Australia & New Zealand" dctSubscribe.Add "4", "African Art (Ethnographic)" dctSubscribe.Add "5", "African Art (Folk Art)" dctSubscribe.Add "6", "Art of Cen. & Sth. America" dctSubscribe.Add "7", "Art of Native North Americans" dctSubscribe.Add "8", "Mexico Artwork" dctSubscribe.Add "9", "Pre-columbian Art" dctSubscribe.Add "10", "Mudcloths" dctSubscribe.Add "11", "Textile Stamps" dctSubscribe.Add "12", "Art of India" dctSubscribe.Add "13", "Art of Nepal & Tibet" set dctPaymentMethod = Server.CreateObject("Scripting.Dictionary") 'dctPaymentMethod.Add "OCC", "Online Credit Card" 'dctPaymentMethod.Add "OEC", "Online Direct Debit" 'dctPaymentMethod.Add "PCC", "Phone-in Credit Card" 'dctPaymentMethod.Add "PEC", "Phone-in Direct Debit" 'dctPaymentMethod.Add "FCC", "Fax-in Credit Card" 'dctPaymentMethod.Add "FEC", "Fax-in Direct Debit" 'dctPaymentMethod.Add "MCC", "Mail-in Credit Card" 'dctPaymentMethod.Add "MEC", "Mail-in Check" 'dctPaymentMethod.Add "MMO", "Mail-in Money Order" 'dctPaymentMethod.Add "FMO", "Fax-in Money Order" 'dctPaymentMethod.Add "PPO", "Phone-in Purchase Order" 'dctPaymentMethod.Add "MPO", "Mail-in Purchase Order" dctPaymentMethod.Add "PAY", "Make payment with PayPal" ' Format for dctTaxZoneRates: ' key: ZoneID~TaxRate ' value: Zone Name set dctTaxZoneRates = Server.CreateObject("Scripting.Dictionary") dctTaxZoneRates.Add "1~7.75", "CA" ' dctTaxZoneRates.Add "2~7.75", "San Bernardino County, CA" ' dctTaxZoneRates.Add "3~7.25", "Any other county in CA" dctTaxZoneRates.Add "0~0", "Other" set dctCreditCardTypeValues = Server.CreateObject("Scripting.Dictionary") dctCreditCardTypeValues.Add "VISA", "Visa" dctCreditCardTypeValues.Add "MASTERCARD", "MasterCard" dctCreditCardTypeValues.Add "AMEX", "American Express" dctCreditCardTypeValues.Add "DISCOVER", "Discover" set dctShipOption = Server.CreateObject("Scripting.Dictionary") dctShipOption.Add "-1", "Custom Shipping" ' custom shipping dctShipOption.Add "1", "US Priority Mail (2-4 day average)" ' US Postal Service 'dctShipOption.Add "2", "UPS Ground" 'dctShipOption.Add "3", "UPS 3 Day Select" 'dctShipOption.Add "4", "UPS 2nd Day Air" 'dctShipOption.Add "5", "UPS Next Day Air" 'dctShipOption.Add "6", "International" 'dctShipOption.Add "7", "Custom" 'dctShipOption.Add "8", "Free Shipping" dctShipOption.Add "9", "FedEx" dctShipOption.Add "10", "DHL" const STR_SHIP_2ndDay = 4 const STR_SHIP_INTRNL = 6 const STR_SHIP_CUSTOM = 7 const STR_SHIP_FREE = 8 Set dctCountryCodes = CreateObject("Scripting.Dictionary") ' don't include the US -- force them to use the Domestic form! ' dctCountryCodes.Add "US", "United States" dctCountryCodes.Add "AR", "Argentina" dctCountryCodes.Add "AU", "Australia" dctCountryCodes.Add "AT", "Austria" dctCountryCodes.Add "BE", "Belgium" dctCountryCodes.Add "BR", "Brazil" dctCountryCodes.Add "CA", "Canada" dctCountryCodes.Add "CL", "Chile" dctCountryCodes.Add "CN", "China" dctCountryCodes.Add "FI", "Finland" dctCountryCodes.Add "FR", "France" dctCountryCodes.Add "DE", "Germany" dctCountryCodes.Add "GR", "Greece" dctCountryCodes.Add "NL", "Holland" dctCountryCodes.Add "HK", "Hong Kong" dctCountryCodes.Add "IN", "India" dctCountryCodes.Add "ID", "Indonesia" dctCountryCodes.Add "IT", "Italy" dctCountryCodes.Add "JP", "Japan" dctCountryCodes.Add "NO", "Norway" dctCountryCodes.Add "MX", "Mexico" dctCountryCodes.Add "PE", "Peru" dctCountryCodes.Add "PH", "Philippines" dctCountryCodes.Add "SG", "Singapore" dctCountryCodes.Add "ZA", "South Africa" dctCountryCodes.Add "SE", "Sweden" dctCountryCodes.Add "CH", "Switzerland" dctCountryCodes.Add "SY", "Syria" dctCountryCodes.Add "TW", "Taiwan" dctCountryCodes.Add "TH", "Thailand" dctCountryCodes.Add "UK", "United Kingdom" dctCountryCodes.Add "UY", "Uruguay" dctCountryCodes.Add "XX", "Other" Set dctUSStateCodes = CreateObject("Scripting.Dictionary") ' dctUSStateCodes.Add "XX", "None" dctUSStateCodes.Add "AL", "Alabama (AL)" dctUSStateCodes.Add "AK", "Alaska (AK)" dctUSStateCodes.Add "AZ", "Arizona (AZ)" dctUSStateCodes.Add "AR", "Arkansas (AR)" dctUSStateCodes.Add "CA", "California (CA)" dctUSStateCodes.Add "CO", "Colorado (CO)" dctUSStateCodes.Add "CT", "Connecticut (CT)" dctUSStateCodes.Add "DC", "District of Columbia (DC)" dctUSStateCodes.Add "DE", "Delaware (DE)" dctUSStateCodes.Add "FL", "Florida (FL)" dctUSStateCodes.Add "GA", "Georgia (GA)" dctUSStateCodes.Add "HI", "Hawaii (HI)" dctUSStateCodes.Add "ID", "Idaho (ID)" dctUSStateCodes.Add "IL", "Illinois (IL)" dctUSStateCodes.Add "IN", "Indiana (IN)" dctUSStateCodes.Add "IA", "Iowa (IA)" dctUSStateCodes.Add "KS", "Kansas (KS)" dctUSStateCodes.Add "KY", "Kentucky (KY)" dctUSStateCodes.Add "LA", "Louisiana (LA)" dctUSStateCodes.Add "ME", "Maine (ME)" dctUSStateCodes.Add "MD", "Maryland (MD)" dctUSStateCodes.Add "MA", "Massachusetts (MA)" dctUSStateCodes.Add "MI", "Michigan (MI)" dctUSStateCodes.Add "MN", "Minnesota (MN)" dctUSStateCodes.Add "MS", "Mississippi (MS)" dctUSStateCodes.Add "MO", "Missouri (MO)" dctUSStateCodes.Add "MT", "Montana (MT)" dctUSStateCodes.Add "NE", "Nebraska (NE)" dctUSStateCodes.Add "NV", "Nevada (NV)" dctUSStateCodes.Add "NH", "New Hampshire (NH)" dctUSStateCodes.Add "NJ", "New Jersey (NJ)" dctUSStateCodes.Add "NM", "New Mexico (NM)" dctUSStateCodes.Add "NY", "New York (NY)" dctUSStateCodes.Add "NC", "North Carolina (NC)" dctUSStateCodes.Add "ND", "North Dakota (ND)" dctUSStateCodes.Add "OH", "Ohio (OH)" dctUSStateCodes.Add "OK", "Oklahoma (OK)" dctUSStateCodes.Add "OR", "Oregon (OR)" dctUSStateCodes.Add "PA", "Pennsylvania (PA)" dctUSStateCodes.Add "PR", "Puerto Rico (PR)" dctUSStateCodes.Add "RI", "Rhode Island (RI)" dctUSStateCodes.Add "SC", "South Carolina (SC)" dctUSStateCodes.Add "SD", "South Dakota (SD)" dctUSStateCodes.Add "TN", "Tennessee (TN)" dctUSStateCodes.Add "TX", "Texas (TX)" dctUSStateCodes.Add "UT", "Utah (UT)" dctUSStateCodes.Add "VT", "Vermont (VT)" dctUSStateCodes.Add "VA", "Virginia (VA)" dctUSStateCodes.Add "VI", "Virgin Islands (VI)" dctUSStateCodes.Add "WA", "Washington (WA)" dctUSStateCodes.Add "WV", "West Virginia (WV)" dctUSStateCodes.Add "WI", "Wisconsin (WI)" dctUSStateCodes.Add "WY", "Wyoming (WY)" ' ===================================================================================== ' Method Set ' Functions: DrawItemHeader ' ' ... ' Subs: AddItemToOrder ' AddItemToOrder_Other ' AddItemToOrderWithOption ' ... ' ===================================================================================== ' GoCart 5 Custom Routines function DrawItemHeader (intParentID, intBackID) dim intTitleID, strCartTitle, rsTitle intBackID = 0 strCartTitle = "" if intParentID > 0 then intTitleID = intParentID while intTitleID > 0 set rsTitle = ConnOpenRS("SELECT intParentID, vchItemName, intID FROM " & STR_TABLE_INVENTORY & " WHERE intID=" & intTitleID) if rsTitle.eof then intTitleID = 0 else if intTitleID = 1 and rsTitle("vchItemName") = "Root" then intBackID = rsTitle("intID") elseif intTitleID <> intParentID then strCartTitle = " - " & rsTitle("vchItemName") & "" & strCartTitle intBackID = rsTitle("intID") else strCartTitle = " - " & rsTitle("vchItemName") & strCartTitle intBackID = 0 end if intTitleID = rsTitle("intParentID") end if rsTitle.close set rsTitle = nothing wend strCartTitle = mid(strCartTitle, 4) if len(strCartTitle) > 0 then strCartTitle = "Online Catalog" & " - " & strCartTitle end if end if DrawItemHeader = strCartTitle end function '-------------------------------------------- function DrawWholesaleItemHeader (intParentID, intBackID) dim intTitleID, strCartTitle, rsTitle intBackID = 0 strCartTitle = "" if intParentID > INT_GOCART_WHOLESALE - 1 then intTitleID = intParentID while intTitleID > INT_GOCART_WHOLESALE - 1 set rsTitle = ConnOpenRS("SELECT intParentID, vchItemName, intID FROM " & STR_TABLE_INVENTORY & " WHERE intID=" & intTitleID) if rsTitle.eof then intTitleID = INT_GOCART_WHOLESALE else if intTitleID = INT_GOCART_WHOLESALE and rsTitle("vchItemName") = "Root" then intBackID = rsTitle("intID") elseif intTitleID <> intParentID then strCartTitle = " - " & rsTitle("vchItemName") & "" & strCartTitle intBackID = rsTitle("intID") else strCartTitle = " - " & rsTitle("vchItemName") & strCartTitle intBackID = INT_GOCART_WHOLESALE end if intTitleID = rsTitle("intParentID") end if rsTitle.close set rsTitle = nothing wend strCartTitle = mid(strCartTitle, 4) if len(strCartTitle) > 0 then strCartTitle = "Top" & " - " & strCartTitle end if end if DrawWholesaleItemHeader = strCartTitle end function '-------------------------------------------- function GetParentID (strTable, intID) dim rsTemp set rsTemp = ConnOpenRS("SELECT intParentID FROM " & strTable & " WHERE intID = " & intID) if rsTemp.EOF then GetParentID = 0 else GetParentID = rsTemp("intParentID") end if rsTemp.close set rsTemp = nothing end function '-------------------------------------------- sub AddItemToOrder(intID, intQuantity) if gintOrderID = 0 then CreateNewOrder end if intQuantity = InStock(intID,intQuantity) if intQuantity > 0 then AddItemToOrder_Other gintOrderID, intID, intQuantity end if end sub '-------------------------------------------- sub AddItemToOrder_Other(intOrderID, intID, intQuantity) dim strItemPrice if not IsNumeric(intQuantity) then intQuantity = 1 else intQuantity = CLng(intQuantity) end if if intQuantity < 1 then intQuantity = 1 end if dim strSQL, rsTemp strSQL = "SELECT intID, ISNULL(intQuantity,0) AS intQuantity FROM " & STR_TABLE_LINEITEM & " WHERE chrStatus='A' AND intOrderID=" & intOrderID & " AND intInvID=" & intID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then dim intItemID intQuantity = intQuantity + rsTemp("intQuantity") intItemID = rsTemp("intID") rsTemp.close set rsTemp = nothing strSQL = "UPDATE " & STR_TABLE_LINEITEM & " SET intQuantity = " & intQuantity & " WHERE intID=" & intItemID gobjConn.execute(strSQL) else rsTemp.close set rsTemp = nothing strSQL = "SELECT * FROM " & STR_TABLE_INVENTORY & " WHERE chrType='I' AND chrStatus='A' AND intID=" & intID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then if rsTemp("mnyWholesale") & "" <> "" then strItemPrice = rsTemp("mnyWholesale") & "" else strItemPrice = rsTemp("mnyItemPrice") & "" end if EditOrderItem_Other intOrderID, 0, intID, rsTemp("vchPartNumber"), rsTemp("vchItemName"), strItemPrice, rsTemp("mnyShipPrice"), rsTemp("chrTaxFlag") = "Y", rsTemp("fltShipWeight"), intQuantity end if rsTemp.close set rsTemp = nothing end if ReCalcOrder_Other intOrderID end sub '-------------------------------------------- sub AddItemToOrderWithOption(intID, intQuantity, strOption1) if gintOrderID = 0 then CreateNewOrder end if intQuantity = InStock(intID,intQuantity) 'Quantity Control Check if intQuantity > 0 then AddItemToOrderWithOption_Other gintOrderID, intID, intQuantity, strOption1 end if end sub '-------------------------------------------- sub AddItemToOrderWithOption_Other(intOrderID, intID, intQuantity, strOptChoice) dim curItemPrice, strItemName dim strSQL, rsTemp strItemName = GetOptionName(strOptChoice, intID) strSQL = "SELECT intID, ISNULL(intQuantity,0) AS intQuantity " strSQL = strSQL & "FROM " & STR_TABLE_LINEITEM & " " strSQL = strSQL & "WHERE (chrStatus='A') " strSQL = strSQL & "AND (intOrderID=" & intOrderID & ") " strSQL = strSQL & "AND (intInvID=" & intID & ") " strSQL = strSQL & "AND (vchItemName='" & strItemName & "')" 'Appended for Option1 purposes set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then 'LineItem already exists intQuantity = intQuantity + CLng(rsTemp("intQuantity")) strSQL = "UPDATE " & STR_TABLE_LINEITEM & " SET intQuantity = " & intQuantity & " WHERE intID=" & CLng(rsTemp("intID")) gobjConn.execute(strSQL) else 'Create the LineItem rsTemp.close set rsTemp = nothing strSQL = "SELECT * FROM " & STR_TABLE_INVENTORY & " WHERE chrType='I' AND chrStatus='A' AND intID=" & intID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then if (rsTemp("mnyWholesale") & "") <> "" then curItemPrice = GetOptionPrice(rsTemp("vchOptionList1") & "", strOptChoice, rsTemp("mnyWholesale") & "") else curItemPrice = GetOptionPrice(rsTemp("vchOptionList1") & "", strOptChoice, rsTemp("mnyItemPrice") & "") end if EditOrderItem_Other intOrderID, 0, intID, rsTemp("vchPartNumber"), strItemName, curItemPrice, rsTemp("mnyShipPrice"), rsTemp("chrTaxFlag") = "Y", "", intQuantity end if end if rsTemp.close set rsTemp = nothing ReCalcOrder_Other intOrderID end sub '-------------------------------------------- sub AddMultipleItemsToOrder (rsItems) dim strItemList, intItemID, intQuantity, strName for each strName in rsItems.Form if Left(strName,7) = "intQty_" then intItemID = Mid(strName,InStr(strName,"_")+1) if IsNumeric(intItemID) then intQuantity = rsItems("intQty_" & intItemID) intQuantity = InStockUPDT(intID, intQuantity) 'Quantity Control Check if IsNumeric(intQuantity) then AddItemToOrder intItemID, intQuantity end if end if end if next end sub '--------------------------------------------- function GetAllQty(intLineItemID, intQuantity) dim strSQL, rsTemp strSQL = "SELECT intQuantity " strSQL = strSQL & "FROM " & STR_TABLE_INVENTORY & " " strSQL = strSQL & "WHERE (intID=" & intLineItemID & ") " strSQL = strSQL & "AND (intOrderID=" & gintOrderID & ") " strSQL = strSQL & "AND (chrStatus = 'A') " set rsTemp = ConnOpenRS(strSQL) GetAllQty = iif( not rsTemp.eof, CLng(rsTemp("intQuantity")) + intQuantity, Clng(intQuantity) ) end function '--------------------------------------------- ' InStockUPDT ' Desc: Determines if enough items are in stock for the ADD request ' Inputs: intID -LineItems intID ' intQty -Quantity desired ' Output: maximum qunatity '--------------------------------------------- function InStockUPDT(intID, intQty) dim strSQL, rsTemp, intNewQty strSQL = "SELECT I.chrStatus, I.intStock, L.intQuantity FROM " & STR_TABLE_INVENTORY & " AS I, " strSQL = strSQL & STR_TABLE_LINEITEM & " AS L " strSQL = strSQL & "WHERE (I.intid = L.intInvID) " strSQL = strSQL & "AND (L.intOrderID = " & gintOrderID & ") " strSQL = strSQL & "AND (L.chrStatus = 'A') " strSQL = strSQL & "AND (L.intID = " & intID & ")" ' response.write strSQL & "
" set rsTemp = ConnOpenRS(strSQL) if IsNumeric(intQty) then intQty = CLng(intQty) else InStockUPDT = 0 exit function 'Wish I could report errors here end if InStockUPDT = intQty if not rsTemp.eof then if rsTemp("chrStatus") & "" <> "A" then 'Is this item available? InStockUPDT = 0 exit function 'Wish I could report errors here end if 'LineItem already exists if not ISNull(rsTemp("intStock")) then if intQty > CLng(rsTemp("intStock")) then InStockUPDT = CLng(rsTemp("intStock")) end if end if else InStockUPDT = intQty end if end function '--------------------------------------------- '--------------------------------------------- ' InStock ' Desc: Determines if enough items are in stock for the ADD request ' Inputs: intID -Items intID ' intQty -Quantity desired ' Output: maximum qunatity '--------------------------------------------- function InStock(intID, intQty) dim strSQL, rsTemp, intNewStock, intNewQty if IsNumeric(intID) then intID = CLng(intID) else InStock = 0 exit function end if if IsNumeric(intQty) then intQty = CLng(intQty) else InStock = 0 exit function end if InStock = intQty if gintOrderID = 0 then 'Order already exists for consumer CreateNewOrder strSQL = "SELECT intStock " strSQL = strSQL & "FROM " & STR_TABLE_INVENTORY & " " strSQL = strSQL & "WHERE (intid = " & intID & ")" ' response.write strSQL set rsTemp = ConnOpenRS(strSQL) if not rsTemp.eof then if not ISNull(rsTemp("intStock")) then if intQty > Clng(rsTemp("intStock")) then InStock = CLng(rsTemp("intStock")) end if end if end if else strSQL = "SELECT I.intStock, L.intQuantity FROM " & STR_TABLE_INVENTORY & " AS I, " strSQL = strSQL & STR_TABLE_LINEITEM & " AS L " strSQL = strSQL & "WHERE (I.intid = L.intInvID) " strSQL = strSQL & "AND (L.intOrderID = " & gintOrderID & ") " strSQL = strSQL & "AND (L.chrStatus = 'A') " strSQL = strSQL & "AND (L.intInvID = " & intID & ")" ' response.write strSQL & "
" set rsTemp = ConnOpenRS(strSQL) if not rsTemp.eof then 'LineItem already exists intNewQty = CLng(rsTemp("intQuantity")) + intQty if not ISNull(rsTemp("intStock")) then if intNewQty > CLng(rsTemp("intStock")) then InStock = CLng(rsTemp("intStock")) - CLng(rsTemp("intQuantity")) end if end if else rsTemp.close strSQL = "SELECT intStock " strSQL = strSQL & "FROM " & STR_TABLE_INVENTORY & " " strSQL = strSQL & "WHERE (intid = " & intID & ")" set rsTemp = ConnOpenRS(strSQL) if not rsTemp.eof then if not ISNull(rsTemp("intStock")) then if intQty > CLng(rsTemp("intStock")) then InStock = CLng(rsTemp("intStock")) end if end if end if end if end if rsTemp.close set rsTemp = nothing end function '-------------------------------------------- function EditOrderItemQty(intLineItemID, intNewQty) if intNewQty > 0 then dim strSQL strSQL = "UPDATE " & STR_TABLE_LINEITEM & " SET intQuantity=" & intNewQty & " WHERE intID=" & intLineItemID & " AND intOrderID=" & gintOrderID gobjConn.execute(strSQL) ReCalcOrder_Other gintOrderID end if end function '-------------------------------------------- function EditOrderItem_Other(intOrderID, intLineItemID, intInvID, strPartNumber, strItemName, mnyUnitPrice, mnyShipPrice, blnTaxable, fltShipWeight, intQuantity) if not IsNumeric(intQuantity) then intQuantity = 1 else intQuantity = CLng(intQuantity) end if if intQuantity < 1 then intQuantity = 1 end if if IsNull(strItemName) or strItemName = "" then strItemName = "Custom Item" end if dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "*@dtmCreated", "GETDATE()" dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "*vchCreatedByUser", "pub" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "*vchCreatedByIP", gstrUserIP dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "chrType", "I" dctSaveList.Add "chrStatus", "A" dctSaveList.Add "#intOrderID", intOrderID dctSaveList.Add "#intInvID", intInvID dctSaveList.Add "vchPartNumber", strPartNumber dctSaveList.Add "vchItemName", strItemName dctSaveList.Add "#mnyUnitPrice", mnyUnitPrice dctSaveList.Add "#mnyShipPrice", mnyShipPrice dctSaveList.Add "#fltShipWeight", fltShipWeight dctSaveList.Add "#intQuantity", intQuantity dctSaveList.Add "chrTaxFlag", iif(blnTaxable, "Y", "N") EditOrderItem_Other = SaveDataRecord("" & STR_TABLE_LINEITEM, Request, intLineItemID, dctSaveList) ReCalcOrder_Other intOrderID end function '-------------------------------------------- function EditOrderNote_Other(intOrderID, intLineItemID, strItemName) dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "*@dtmCreated", "GETDATE()" dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "*vchCreatedByUser", "pub" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "*vchCreatedByIP", gstrUserIP dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "chrType", "N" dctSaveList.Add "chrStatus", "A" dctSaveList.Add "#intOrderID", intOrderID ' dctSaveList.Add "#intInvID", intInvID ' dctSaveList.Add "vchPartNumber", strPartNumber dctSaveList.Add "vchItemName", strItemName ' dctSaveList.Add "#mnyUnitPrice", mnyUnitPrice ' dctSaveList.Add "#mnyShipPrice", mnyShipPrice ' dctSaveList.Add "#intQuantity", intQuantity ' dctSaveList.Add "chrTaxFlag", iif(blnTaxable, "Y", "N") EditOrderNote_Other = SaveDataRecord("" & STR_TABLE_LINEITEM, Request, intLineItemID, dctSaveList) ReCalcOrder_Other intOrderID end function '-------------------------------------------- function EditOrderReturn_Other(intOrderID, intItemID, intInvID, strPartNumber, strReturnName, strReturnPrice, strReturnShip, blnTaxable, intQuantity) if not IsNumeric(intQuantity) then intQuantity = 1 else intQuantity = CLng(intQuantity) end if if intQuantity < 1 then intQuantity = 1 end if dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "*@dtmCreated", "GETDATE()" dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "*vchCreatedByUser", "pub" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "*vchCreatedByIP", gstrUserIP dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "chrType", "R" dctSaveList.Add "chrStatus", "A" dctSaveList.Add "#intOrderID", intOrderID dctSaveList.Add "#intInvID", intInvID dctSaveList.Add "vchPartNumber", strPartNumber dctSaveList.Add "vchItemName", strReturnName dctSaveList.Add "#mnyUnitPrice", strReturnPrice dctSaveList.Add "#mnyShipPrice", strReturnShip dctSaveList.Add "#intQuantity", intQuantity dctSaveList.Add "chrTaxFlag", iif(blnTaxable, "Y", "N") EditOrderReturn_Other = SaveDataRecord("" & STR_TABLE_LINEITEM, Request, intItemID, dctSaveList) ReCalcOrder_Other intOrderID end function '-------------------------------------------- sub RemoveLineFromOrder(intItemID) RemoveLineFromOrder_Other gintOrderID, intItemID end sub '-------------------------------------------- sub RemoveLineFromOrder_Other(intOrderID, intItemID) dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "chrStatus", "D" dctSaveList.Add "#intQuantity", 0 SaveDataRecord STR_TABLE_LINEITEM, Request, intItemID, dctSaveList ReCalcOrder_Other intOrderID end sub '-------------------------------------------- sub ReCalcOrder ReCalcOrder_Other gintOrderID end sub '-------------------------------------------- sub ReCalcOrder_Other(intOrderID) if intOrderID > 0 then gintOrderID = intOrderID ' recalculate the following fields: ' mnyShipAmount ' chrShipTaxFlag ' mnyNonTaxSubtotal ' mnyTaxSubtotal ' fltTaxRate ' mnyGrandTotal ' business logic: ' shipping is NOT taxable ' shipping price is set in inventory, fixed price per item ordered dim strSQL, rsTemp, mnyNonTaxSubtotal, mnyTaxSubtotal, mnyShipSubtotal, mnyTaxAmount, mnyGrandTotal mnyNonTaxSubtotal = 0 mnyTaxSubtotal = 0 mnyShipSubtotal = 0 ' step 1: calculate sum of taxable and non-taxable items ordered, and shipping cost 'not applicable here, deb if true = false then strSQL = "SELECT SUM(mnyUnitPrice*intQuantity) AS mnyPrice, SUM(mnyShipPrice*intQuantity) AS mnyShipPrice, ISNULL(chrTaxFlag,'N') AS chrTaxFlag FROM " & STR_TABLE_LINEITEM & " WHERE intOrderID=" & intOrderID & " AND chrStatus='A' AND (chrType='I' OR chrType='R') GROUP BY chrTaxFlag" set rsTemp = gobjConn.execute(strSQL) while not rsTemp.eof if not IsNull(rsTemp("mnyPrice")) then if lcase(rsTemp("chrTaxFlag")) = "y" then mnyTaxSubtotal = mnyTaxSubtotal + rsTemp("mnyPrice") else mnyNonTaxSubtotal = mnyNonTaxSubtotal + rsTemp("mnyPrice") end if end if if not IsNull(rsTemp("mnyShipPrice")) then mnyShipSubtotal = mnyShipSubtotal + rsTemp("mnyShipPrice") end if rsTemp.MoveNext wend rsTemp.close set rsTemp = nothing ' shipping cost calculation: dim intShipOption, mnySubtotal intShipOption = GetOrderShipOption_Other(intOrderID) if intShipOption <> -1 then mnyShipSubtotal = mnyShipSubtotal + GetShipPriceByOption(mnySubTotal, intShipOption) else 'custom shipping price set by merchant mnyShipSubtotal = mnyShipSubtotal + GetOrderShippingPrice_Other(intOrderID) end if ' for this cart, shipping is NOT taxable! ' add shipping cost to non-taxable subtotal mnyNonTaxSubtotal = mnyNonTaxSubtotal + mnyShipSubtotal ' response.write "non: " & mnynontaxsubtotal & "
" ' step 2: calculate tax rate based on tax zone dim intTaxZone, fltTaxRate strSQL = "SELECT ISNULL(intTaxZone,0) AS intTaxZone FROM " & STR_TABLE_ORDER & " WHERE intID=" & intOrderID set rsTemp = gobjConn.execute(strSQL) intTaxZone = rsTemp("intTaxZone") rsTemp.close set rsTemp = nothing ' if intTaxZone = 0 then products shipped out-side the state fltTaxRate = FindTaxRate(intTaxZone) if fltTaxRate = 0 then ' no taxes apply to this order mnyNonTaxSubtotal = mnyNonTaxSubtotal + mnyTaxSubtotal mnyTaxSubtotal = 0 mnyTaxAmount = 0 else ' calculate tax mnyTaxAmount = mnyTaxSubtotal * fltTaxRate end if end if 'end true = false 'following portion added by Deb '---------------------------------- dim rsInv, rsOrder dim singleItemPrice, shipPrice, qty, deliveredAddress dim numAddrXS_50 'get unitItemPrice and shipPrice strSQL = "SELECT mnyItemPrice, mnyShipPrice FROM " & STR_TABLE_INVENTORY & " WHERE intID= 1 AND chrStatus='A' AND (chrType='I' OR chrType='R')" set rsInv = gobjConn.execute(strSQL) if not rsInv.eof then singleItemPrice = rsInv("mnyItemPrice") shipPrice = rsInv("mnyShipPrice") end if rsInv.Close set rsInv = nothing 'get delivered address (C: customer, G:guest) strSQL = "SELECT intQuantity, chrDeliveredAddress FROM " & STR_TABLE_ORDER & " WHERE intID= " & intOrderID set rsOrder = gobjConn.execute(strSQL) if not rsOrder.eof then qty = rsOrder("intQuantity") deliveredAddress = rsOrder("chrDeliveredAddress") end if rsOrder.Close set rsOrder = nothing 'calculate shipping if deliveredAddress = "G" then shipPrice = qty * shipPrice else shipPrice = 0 end if 'calculate grandTotal if qty > 50 then numAddrXS_50 = qty - 50 mnyGrandTotal = 50 + (singleItemPrice*numAddrXS_50) else 'strNumAddr = 50 'mnyGrandTotal = (qty * singleItemPrice) mnyGrandTotal = qty end if 'mnyGrandTotal = (singleItemPrice * qty) + shipPrice mnyGrandTotal = mnyGrandTotal + shipPrice ' save results dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "#mnyShipAmount", shipPrice dctSaveList.Add "#mnyGrandTotal", mnyGrandTotal SaveDataRecord STR_TABLE_ORDER, Request, intOrderID, dctSaveList strSQL = "UPDATE " & STR_TABLE_LINEITEM strSQL = strSQL & " SET mnyShipPrice = " & shipPrice strSQL = strSQL & " WHERE intOrderID = " & intOrderID gobjConn.execute(strSQL) '----------------------------------- if true = false then 'added by deb ' save results mnyGrandTotal = mnyNonTaxSubtotal + mnyTaxSubtotal + mnyTaxAmount 'dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "#mnyNonTaxSubtotal", mnyNonTaxSubtotal dctSaveList.Add "#mnyTaxSubtotal", mnyTaxSubtotal dctSaveList.Add "#mnyTaxAmount", mnyTaxAmount dctSaveList.Add "#mnyShipAmount", mnyShipSubtotal dctSaveList.Add "chrShipTaxFlag", "N" dctSaveList.Add "#intTaxZone", intTaxZone dctSaveList.Add "#fltTaxRate", fltTaxRate dctSaveList.Add "#mnyGrandTotal", mnyGrandTotal SaveDataRecord STR_TABLE_ORDER, Request, intOrderID, dctSaveList end if end if end sub '-------------------------------------------- sub RemoveItemFromOrder(intID) if isnumeric(intID) then intID = clng(intID) else intID = 0 end if if gintOrderID > 0 then dim strSQL strSQL = "UPDATE " & STR_TABLE_LINEITEM & " SET chrStatus='D' WHERE intID=" & intID & " AND intOrderID=" & gintOrderID gobjConn.execute(strSQL) end if end sub '-------------------------------------------- function FindTaxRate(byVal intTaxZone) FindTaxRate = 0 dim k, c, x, s, xLen intTaxZone = intTaxZone & "~" xLen = len(intTaxZone) x = dctTaxZoneRates.count - 1 k = dctTaxZoneRates.keys for c = 0 to x if left(k(c), xLen) = intTaxZone then ' found it! FindTaxRate = CDbl(mid(k(c), xLen + 1)) / 100 exit function end if next end function '-------------------------------------------- function GetTaxZoneList() ' returns a dictionary list of tax zones {tax zone, label } set GetTaxZoneList = Server.CreateObject("Scripting.Dictionary") dim k, c, x, s, pos, i x = dctTaxZoneRates.count - 1 k = dctTaxZoneRates.keys i = dctTaxZoneRates.items for c = 0 to x pos = InStr(k(c), "~") GetTaxZoneList.Add left(k(c), pos - 1), i(c) next end function '-------------------------------------------- function GetTaxZoneName(intTaxZone) GetTaxZoneName = "" dim k, c, x, s, xLen, i intTaxZone = intTaxZone & "~" xLen = len(intTaxZone) x = dctTaxZoneRates.count - 1 k = dctTaxZoneRates.keys i = dctTaxZoneRates.items for c = 0 to x if left(k(c), xLen) = intTaxZone then ' found it! GetTaxZoneName = i(c) exit function end if next end function '-------------------------------------------- sub DrawOrderCart(rsOrder, rsLineItem, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn) %>
<% if blnCanEdit then %> <% end if %> <% dim strColor strColor = "" while not rsLineItem.eof if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% if rsLineItem("chrType") = "I" or rsLineItem("chrType") = "R" then %> > <% if blnCanEdit then %> <% end if %> <% end if rsLineItem.MoveNext wend if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% ' Shipping: xx ' Nontaxable Subtotal: xx ' Taxable Subtotal: xx ' Tax: xx ' Total: xx if not IsNull(rsOrder("mnyShipAmount")) then if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% end if dim mnyTaxSubTotal, mnyNonTaxSubTotal if not IsNull(rsOrder("mnyNonTaxSubtotal")) then mnyNonTaxSubTotal = rsOrder("mnyNonTaxSubtotal") else mnyNonTaxSubTotal = 0 end if if not IsNull(rsOrder("mnyTaxSubtotal")) then mnyTaxSubTotal = rsOrder("mnyTaxSubTotal") else mnyTaxSubTotal = 0 end if if mnyTaxSubTotal = 0 or mnyNonTaxSubTotal = 0 then ' only one subtotal--we'll list it as "Subtotal" if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% else if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% end if if rsOrder("mnyTaxAmount") <> 0 and not IsNull(rsOrder("mnyTaxAmount")) then if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %> <% end if if strColor = "" then strColor = " BGCOLOR=""#DDDDDD""" else strColor = "" %> > <% if blnCanEdit then %> <% end if %>
PART # ITEM SUBTOTAL 
<%= rsLineItem("vchPartNumber") %>  <%= rsLineItem("vchItemName") %> <%= replace(iif(rsLineItem("chrType") = "I", strAuxMsgItem, iif(rsLineItem("chrType") = "R", strAuxMsgReturn, strAuxMsgNote)), "$ID$", rsLineItem("intID")) %>
  <%= SafeFormatCurrency(" ", rsLineItem("mnyUnitPrice"), 2) %> S/H: <%= SafeFormatCurrency(" ", rsLineItem("mnyShipPrice"), 2) %> Qty: <%= iif(IsNull(rsLineItem("intQuantity")), " ", rsLineItem("intQuantity")) %> <%= SafeFormatCurrency(" ", rsLineItem("mnyPrice"), 2) %> 
    
(<%= GetArrayValue(rsOrder("intShipOption"), dctShipOption) %>) Shipping:  <%= SafeFormatCurrency("$0.00", rsOrder("mnyShipAmount"), 2) %> 
Subtotal:  <%= FormatCurrency(mnyTaxSubTotal + mnyNonTaxSubTotal, 2) %> 
Taxable Subtotal:  <%= FormatCurrency(mnyTaxSubtotal, 2) %> 
Non-Taxable Subtotal:  <%= FormatCurrency(mnyNonTaxSubtotal, 2) %> 
(<%= GetTaxZoneName(rsOrder("intTaxZone")) %>) Tax @ <%= SafeFormatNumber("0", rsOrder("fltTaxRate") * 100, 2) %>%:  <%= SafeFormatCurrency("n/a", rsOrder("mnyTaxAmount"), 2) %> 
Total:  <%= SafeFormatCurrency("$0.00", rsOrder("mnyGrandTotal"), 2) %> 
<% end sub '-------------------------------------------- sub Merchant_DrawOrderCart(rsOrder, rsLineItem, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn, byVal cBGColor) response.write GetMerchant_DrawOrderCart(rsOrder, rsLineItem, true, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn, cBGColor) end sub '-------------------------------------------- function GetMerchant_DrawOrderCart(rsOrder, rsLineItem, blnAdmin, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn, byVal cBGColor) dim strActionLabel, PhotoURL, intwidth, intheight, strImageURL ' strActionLabel = iif(blnCanEdit, "Edit", "Move") strActionLabel = "" intwidth = 21 intheight = 19 dim s s = "" dim strGiftMessage strGiftMessage = rsOrder("txtGiftMessage") & "" if cBGColor = "" then cBGColor = cVLtYellow end if s = s & "" s = s & "" s = s & "
" s = s & "" s = s & " " if blnAdmin then s = s & " " else s = s & " " end if s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" dim strColor strColor = "" while not rsLineItem.eof if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" if blnAdmin and rsLineItem("chrType") = "I" then strImageURL = rsLineItem("vchImageURL") if IsNull(strImageURL) or strImageURL = "" then ' PhotoURL = "" PhotoURL = " " else 'PhotoURL = "" PhotoURL = "" end if s = s & " " else s = s & " " end if ' if blnAdmin then s = s & " " ' else ' s = s & " " ' end if s = s & " " if blnCanEdit then s = s & " " end if s = s & "" '--------------------show details for EXSWest--------------------------- s = s & "" s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " s = s & "" '--------------------------------------- if rsLineItem("chrType") = "I" or rsLineItem("chrType") = "R" then s = s & "" s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" end if rsLineItem.MoveNext wend if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" ' Shipping: xx ' Nontaxable Subtotal: xx ' Taxable Subtotal: xx ' Tax: xx ' Total: xx dim mnyTaxSubTotal, mnyNonTaxSubTotal, mnyTaxAmount, mnyShipAmount if not IsNull(rsOrder("mnyNonTaxSubtotal")) then mnyNonTaxSubTotal = rsOrder("mnyNonTaxSubtotal") else mnyNonTaxSubTotal = 0 end if if not IsNull(rsOrder("mnyTaxSubtotal")) then mnyTaxSubTotal = rsOrder("mnyTaxSubTotal") else mnyTaxSubTotal = 0 end if if not IsNull(rsOrder("mnyTaxAmount")) then mnyTaxAmount = rsOrder("mnyTaxAmount") else mnyTaxAmount = 0 end if if not IsNull(rsOrder("mnyShipAmount")) then mnyShipAmount = rsOrder("mnyShipAmount") else mnyShipAmount = 0 end if if mnyShipAmount > 0 then if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " 's = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" end if ' -- shipping is non-taxable for this site 'if mnyNonTaxSubTotal > mnyShipAmount and mnyNonTaxSubTotal > 0 ' mnyNonTaxSubTotal = mnyNonTaxSubTotal - mnyShipAmount 'end if if mnyTaxSubTotal = 0 or mnyNonTaxSubTotal = 0 then ' only one subtotal--we'll list it as "Subtotal" if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " '---------- customozation for EXSWest --------------- s = s & " " s = s & " " 's = s & " " 's = s & " " '-------------------------------------------------- if blnCanEdit then s = s & " " end if s = s & "" else if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" end if if mnyTaxAmount <> 0 then if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" end if if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" s = s & "
 Part #  ItemSub-Total 
" & PhotoURL & " " & iif(blnAdmin,rsLineItem("vchPartNumber"),"") & "  " & rsLineItem("vchItemName") & " " & replace(iif(rsLineItem("chrType") = "I", strAuxMsgItem, iif(rsLineItem("chrType") = "R", strAuxMsgReturn, strAuxMsgNote)), "$ID$", rsLineItem("intID")) & "
 Price/unit: " & SafeFormatCurrency(" ", rsLineItem("mnyUnitPrice"), 2) & "S/H: " & SafeFormatCurrency(" ", rsLineItem("mnyShipPrice"), 2) & "Qty: " & iif(IsNull(rsLineItem("intQuantity")), " ", rsLineItem("intQuantity")) & "
" & iif(rsLineItem("chrType") = "R", "RETURNED", " ") & "Price/unit: " & SafeFormatCurrency(" ", rsLineItem("mnyUnitPrice"), 2) & "S/H: " & SafeFormatCurrency(" ", rsLineItem("mnyShipPrice"), 2) & "Qty: " & iif(IsNull(rsLineItem("intQuantity")), " ", rsLineItem("intQuantity")) & "" & SafeFormatCurrency(" ", rsLineItem("mnyPrice"), 2) & " 
    
 (" & GetArrayValue(rsOrder("intShipOption"), dctShipOption) & ") + S/H: S/H: " & SafeFormatCurrency("$0.00", rsOrder("mnyShipAmount"), 2) & " 
  Subtotal: " & FormatCurrency(mnyTaxSubTotal + mnyNonTaxSubTotal, 2) & " 
 Taxable Subtotal: " & FormatCurrency(mnyTaxSubtotal, 2) & " 
 Non-Taxable Subtotal: " & FormatCurrency(mnyNonTaxSubtotal, 2) & " 
 (" & GetTaxZoneName(rsOrder("intTaxZone")) & ") Tax @ " & SafeFormatNumber("0", rsOrder("fltTaxRate") * 100, 2) & "%: " & SafeFormatCurrency("n/a", mnyTaxAmount, 2) & " 
 Total: " & SafeFormatCurrency("$0.00", rsOrder("mnyGrandTotal"), 2) & " 
" ' *** END PAYMENT OPTIONS *** 'if IsValid(strGiftMessage) then ' *** BEGIN GIFT MESSAGE *** 's = s & "
" 's = s & "
" 's = s & "
Comments:
" 's = s & " " & strGiftMessage & "" 's = s & "
" 's = s & "
" 'end if GetMerchant_DrawOrderCart = s end function '-------------------------------------------- ' rkonvalin - added Brand_DrawOrderCart 2/7/03 ' does not show dollar amounts on orders so Brand (Partner) can see/fill/ship items on orders by brand sub Brand_DrawOrderCart(rsOrder, rsLineItem, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn, byVal cBGColor, byVal cBGShipColor) response.write GetBrand_DrawOrderCart(rsOrder, rsLineItem, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn, cBGColor, cBGShipColor) end sub '-------------------------------------------- function GetBrand_DrawOrderCart(rsOrder, rsLineItem, blnCanEdit, strAuxMsgItem, strAuxMsgNote, strAuxMsgReturn, byVal cBGColor, cBGShipColor) dim s s = "" if cBGColor = "" then cBGColor = cVLtYellow end if s = s & "" s = s & "" s = s & "
" s = s & "" s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" dim strColor strColor = "" while not rsLineItem.eof if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " if blnCanEdit then s = s & " " end if if rsLineItem("chrType") = "I" or rsLineItem("chrType") = "R" then s = s & " " s = s & " " s = s & " " end if s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" rsLineItem.MoveNext wend if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" s = s & "" s = s & " " s = s & " " s = s & " " if blnCanEdit then s = s & " " end if s = s & "" s = s & "" ' Shipping: xx if not IsNull(rsOrder("mnyShipAmount")) then if strColor = "" then strColor = " BGCOLOR=""#EEEEEE""" else strColor = "" if cBGShipColor <> "" then strColor = " BGCOLOR=""" & cBGShipColor & """" end if s = s & "" s = s & " " s = s & " " 'rsOrder("mnyShipAmount") if blnCanEdit then s = s & " " end if s = s & "" end if s = s & "
Item #ProductShip DateShipping #  
" & rsLineItem("vchPartNumber") & " " & rsLineItem("vchItemName") & " " & replace(iif(rsLineItem("chrType") = "I", strAuxMsgItem, iif(rsLineItem("chrType") = "R", strAuxMsgReturn, strAuxMsgNote)), "$ID$", rsLineItem("intID")) & "" if (rsLineItem("chrType") = "R") then s = s & "RETURNED" else s = s & " " end if s = s & "" if (not IsNull(rsLineItem("intForceShipMethod"))) then s = s & "Must Ship By " & GetArrayValue(rsLineItem("intForceShipMethod"), dctShipOption) & "  " end if if (rsLineItem("chrForceSoloItem") & "" = "Y") then s = s & "(Individually)  " end if s = s & "Qty: " & iif(IsNull(rsLineItem("intQuantity")), " ", rsLineItem("intQuantity")) & "" & iif(IsNull(rsLineItem("vchShippingNumber")), " ", formatdatetime(rsLineItem("dtmUpdated"), 2)) & "" & iif(IsNull(rsLineItem("vchShippingNumber")), " ", rsLineItem("vchShippingNumber")) & "  
    
(" & GetArrayValue(rsOrder("intShipOption"), dctShipOption) & ") Shipping: " & SafeFormatCurrency("$0.00", 0, 2) & " 
" GetBrand_DrawOrderCart = s end function '-------------------------------------------- Function getRealWords(inArray) Dim lCount, lCurWord, i, j, isGood dim checkArr checkArr = Array("a","and","the","in","of","or") Redim tempArray(UBound(inArray)+1) lCount = 0 For i = 0 to UBound(inArray) lCurWord = inArray(i) ' response.write lCurWord & "
" if len(lCurWord) > 0 then isGood = true For j = 0 to UBound(checkArr) if lCurWord = checkArr(j) then isGood = false exit For end if Next if isGood then tempArray(lCount) = lCurWord lCount = lCount + 1 end if end if Next if lCount > 0 then lCount = lCount - 1 end if ReDim Preserve tempArray(lCount) getRealWords = tempArray End function '-------------------------------------------- function Inventory_GetItemsFromFolder(intParentID, blnGetFolders, blnGetItems) dim strSQL strSQL = "SELECT intParentID, intID, chrType, chrStatus, intMinQty, intStock, vchImageURL, intImageHeight, intImageWidth, mnyItemPrice, mnyShipPrice, chrSoftFlag, vchItemName, vchPartNumber, fltShipWeight, vchSize, vchPack, vchUnit, txtDescription" strSQL = strSQL & " FROM " & STR_TABLE_INVENTORY strSQL = strSQL & " WHERE chrStatus='A' AND chrParentStatus='A' AND (intParentID=" & intParentID & " OR intID=" & intParentID & ")" if blnGetFolders and not blnGetItems then strSQL = strSQL & " AND chrType='A'" elseif not blnGetFolders and blnGetItems then strSQL = strSQL & " AND chrType='I'" end if strSQL = strSQL & " ORDER BY chrType, intSortOrder" 'if intParentID = 4 then ' response.write strSQL & "
" 'end if set Inventory_GetItemsFromFolder = gobjConn.execute(strSQL) end function '-------------------------------------------- function Inventory_GetItemsByKeyword(byVal strKeywords) dim strSQL strKeywords = SQLEncode(strKeywords) strSQL = "SELECT intParentID, intID, chrType, chrStatus, intStock, vchImageURL, intImageHeight, intImageWidth, mnyItemPrice, mnyShipPrice, chrSoftFlag, vchItemName, vchPartNumber, fltShipWeight, vchSize, vchPack, vchUnit, txtDescription" strSQL = strSQL & " FROM " & STR_TABLE_INVENTORY strSQL = strSQL & " WHERE chrStatus='A' and chrParentStatus='A'" strSQL = strSQL & " AND chrType='I'" strSQL = strSQL & " AND (vchItemName LIKE '%" & strKeywords & "%'" strSQL = strSQL & " OR vchPartNumber LIKE '%" & strKeywords & "%'" strSQL = strSQL & " OR txtDescription LIKE '%" & strKeywords & "%'" & ")" strSQL = strSQL & " ORDER BY intSortOrder" set Inventory_GetItemsByKeyword = gobjConn.execute(strSQL) end function '-------------------------------------------- sub Custom_GetGlobalInventoryFolders(intParentID) if IsObject(gobjConn) then set grsInvFolders = Inventory_GetItemsFromFolder(intParentID, true, false) end if end sub '-------------------------------------------- sub Inventory_GetFolderInfo(intParentID, strPageTitle, intParentUpID) intParentUpID = 0 strPageTitle = "" dim strSQL, rsTemp strSQL = "SELECT intParentID, vchItemName FROM " & STR_TABLE_INVENTORY & " WHERE intID=" & intParentID & " AND chrStatus='A'" ' response.write strSQL & "
" set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then intParentUpID = rsTemp("intParentID") strPageTitle = rsTemp("vchItemName") end if rsTemp.close set rsTemp = nothing end sub '-------------------------------------------- sub Inventory_GetItemInfo(intID, intParentID, strItemName, strPartNumber, intStock, strImageURL, mnyItemPrice, mnyShipPrice, blnTaxFlag, fltShipWeight, vchSize, vchPack, vchUnit, blnFreeShip, strOptionList1, strOptionList2, strDescription) intParentID = 0 strItemName = "" strPartNumber = "" intStock = 0 strImageURL = "" mnyItemPrice = 0 mnyShipPrice = 0 blnTaxFlag = false blnFreeShip = false fltShipWeight = 0 strOptionList1 = "" strOptionList2 = "" vchSize = "" vchPack = "" vchUnit = "" strDescription = "" dim strSQL, rsTemp strSQL = "SELECT intParentID, vchItemName, vchPartNumber, intStock, vchImageURL, mnyItemPrice, mnyShipPrice, chrTaxFlag, chrSoftFlag, fltShipWeight, vchSize, vchPack, vchUnit, vchOptionList1, vchOptionList2, txtDescription FROM " & STR_TABLE_INVENTORY & " WHERE intID=" & intID & " AND chrStatus='A'" ' if intID = 4 then ' response.write strSQL & "
" ' end if set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then intParentID = rsTemp("intParentID") strItemName = rsTemp("vchItemName") & "" strPartNumber = rsTemp("vchPartNumber") & "" intStock = rsTemp("intStock") strImageURL = rsTemp("vchImageURL") & "" mnyItemPrice = rsTemp("mnyItemPrice") mnyShipPrice = rsTemp("mnyShipPrice") blnTaxFlag = (rsTemp("chrTaxFlag") = "Y") fltShipWeight = rsTemp("fltShipWeight") vchSize = rsTemp("vchSize") vchPack = rsTemp("vchPack") vchUnit = rsTemp("vchUnit") strOptionList1 = rsTemp("vchOptionList1") & "" strOptionList2 = rsTemp("vchOptionList2") & "" strDescription = rsTemp("txtDescription") & "" end if rsTemp.close set rsTemp = nothing end sub '-------------------------------------------- sub Inventory_UpdateHitCount(intID) dim strSQL strSQL = "UPDATE " & STR_TABLE_INVENTORY & " SET intHitCount=intHitCount+1 WHERE intID=" & intID ConnExecute strSQL end sub '-------------------------------------------- sub Inventory_ResetHitCount(intID) dim strSQL strSQL = "UPDATE " & STR_TABLE_INVENTORY & " SET intHitCount=0, dtmHitReset=getdate() WHERE intID=" & intID ConnExecute strSQL end sub '-------------------------------------------- sub SendInvoiceMail(rsInput, strMessage, strEmail1, strEmail2, strEmail3) dim s, strEmailAddress strEmailAddress = strEmail1 if strEmail2 <> "" then if strEmailAddress <> "" then strEmailAddress = strEmailAddress & ";" strEmailAddress = strEmailAddress & strEmail2 end if if strEmail3 <> "" then if strEmailAddress <> "" then strEmailAddress = strEmailAddress & ";" strEmailAddress = strEmailAddress & strEmail3 end if s = GetInvoiceHTML(rsInput, strMessage) if lcase(strServerHost) = "awsdev" then ' running from internal s = s & vbcrlf & "To: " & strEmailAddress & vbcrlf & vbcrlf strEmailAddress = "dde@americanwebservices.com" end if SendHTMLMail STR_MERCHANT_EMAIL, strEmailAddress, "", "", "Copy of Invoice - Order #" & STR_MERCHANT_TRACKING_PREFIX & rsInput("intID"), s end sub '-------------------------------------------- function GetInvoiceHTML(rsInput, strMessage) dim s, strSQL dim rsLineItem, rsShopper, strColor dim blnErrors, dctErrorList dim strStatus, strStatusText, strStatusCode strStatusCode = rsInput("chrStatus") strStatus = GetArrayValue(strStatusCode, dctOrderStatusInvoiceValues) select case rsInput("chrStatus") case "0","1","2","3","4","5","6","7","8", "P", "9": ' in progress strStatusText = "This order has not yet been submitted." case "S", "A", "Z", "V", "E": ' submitted strStatusText = "This order has been submitted for processing." case "X", "H": ' deposited strStatusText = "This order has been shipped." case "C": ' credited strStatusText = "Funds have been returned to purchaser." case "B": ' abandoned case "K": ' declined end select s = "" ' HTML Header s = s & "" s = s & "" s = s & "" s = s & " Copy of Invoice - Order #-" & STR_MERCHANT_TRACKING_PREFIX & rsInput("intID") & "" s = s & " " s = s & "" s = s & "" s = s & "" s = s & "" s = s & " " s = s & "" s = s & "
" ' BODY s = s & "
" s = s & "" & STR_MERCHANT_NAME & "
" s = s & STR_MERCHANT_ADDRESS1 & iif(STR_MERCHANT_ADDRESS2 <> "", ", " & STR_MERCHANT_ADDRESS2, "") & "
" s = s & STR_MERCHANT_CITY & ", " & STR_MERCHANT_STATE & " " & STR_MERCHANT_ZIP & "
" s = s & "Phone " & STR_MERCHANT_PHONE & "  Fax " & STR_MERCHANT_FAX s = s & "
" s = s & "
" if strMessage <> "" then s = s & "" s = s & "" s = s & " " s = s & "" s = s & "
" & strMessage & "
" s = s & "
" end if 'stlBeginStdTable "100%" s = s & "" s = s & "" s = s & " " s = s & " " s = s & " " s = s & "" s = s & "" s = s & " " s = s & " " s = s & " " s = s & "" s = s & "" s = s & " " s = s & "" s = s & "" s = s & " " s = s & " " s = s & " " s = s & "" s = s & "" s = s & " " s = s & " " s = s & " " s = s & "" s = s & "
Created:Submitted:Updated:
  " & FormatDateTimeNoSeconds(rsInput("dtmCreated")) & "     " & FormatDateTimeNoSeconds(rsInput("dtmSubmitted")) & "     " & FormatDateTimeNoSeconds(rsInput("dtmUpdated")) & "   
 
Tracking Number:Account:Shipping #:
  " & STR_MERCHANT_TRACKING_PREFIX & rsInput("intID") & "     " & rsInput("A_vchShopperAccount") & "     " & rsInput("vchShippingNumber") & "   
" s = s & "
" s = s & "" s = s & "" s = s & " " s = s & "" s = s & "" s = s & " " s = s & "" s = s & "
Status:
  " & strStatus & " - " & strStatusText & "
" s = s & "
" s = s & "" s = s & "" s = s & " " s = s & "" s = s & "" s = s & " " s = s & "" s = s & "
Payment Information:
" s = s & "  " & GetArrayValue(rsInput("chrPaymentMethod"), dctPaymentMethod) if right(rsInput("chrPaymentMethod"), 2) = "CC" then if not IsNull(rsInput("vchPaymentCardNumber")) then s = s & " " & rsInput("vchPaymentCardType") & " " & GetProtectedCardNumber(rsInput("vchPaymentCardNumber")) & " (exp " & rsInput("chrPaymentCardExpMonth") & "/" & rsInput("chrPaymentCardExpyear") & ")" end if elseif right(rsInput("chrPaymentMethod"), 2) = "EC" then s = s & " " & rsInput("vchPaymentBankName") & " " & rsInput("vchPaymentRtnNumber") & "-" & GetProtectedCardNumber(rsInput("vchPaymentAcctNumber")) & " " & rsInput("vchPaymentCheckNumber") end if s = s & "
" s = s & "
" s = s & "" s = s & "" s = s & " " s = s & " " s = s & "" s = s & "
" s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " s = s & "
Bill To:
" if isNull(rsInput("intBillShopperID")) or IsNull(rsInput("intShopperID")) then s = s & "  no information" else strSQL = "SELECT * FROM " & STR_TABLE_SHOPPER & " WHERE intID=" & rsInput("intBillShopperID") & " AND chrStatus<>'D' AND chrType='B' AND intShopperID=" & rsInput("intShopperID") set rsShopper = gobjConn.execute(strSQL) if rsShopper.eof then s = s & "  System error--unable to retrieve shopper information." else s = s & "  " & rsShopper("vchLastName") & ", " & rsShopper("vchFirstName") & "
" if not IsNull(rsShopper("vchCompany")) then s = s & "  " & rsShopper("vchCompany") & "
" end if if not IsNull(rsShopper("vchAddress1")) then s = s & "  " & rsShopper("vchAddress1") & "
" end if if not IsNull(rsShopper("vchAddress2")) then s = s & "  " & rsShopper("vchAddress2") & "
" end if s = s & "  " & rsShopper("vchCity") & ", " & rsShopper("vchState") & " " & rsShopper("vchZip") & "
" if not IsNull(rsShopper("vchCountry")) then s = s & "  " & rsShopper("vchCountry") & "
" end if if not IsNull(rsShopper("vchDayPhone")) then s = s & "  Day: " & rsShopper("vchDayPhone") & "
" end if if not IsNull(rsShopper("vchNightPhone")) then s = s & "  Night: " & rsShopper("vchNightPhone") & "
" end if if not IsNull(rsShopper("vchFax")) then s = s & "  Fax: " & rsShopper("vchFax") & "
" end if if not IsNull(rsShopper("vchEmail")) then s = s & "  Email: " & rsShopper("vchEmail") & "
" end if end if rsShopper.close set rsShopper = nothing end if s = s & "
" if ucase(rsInput("chrDeliveredAddress")) = "C" then s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " s = s & " " end if 'if rsInput("chrDeliveredAddress") = "C" s = s & "
Ship To:
" if IsNull(rsInput("intShipShopperID")) or isNull(rsInput("intShopperID")) then s = s & "  no information" else strSQL = "SELECT * FROM " & STR_TABLE_SHOPPER & " WHERE intID=" & rsInput("intShipShopperID") & " AND chrStatus<>'D' and (chrType='S' OR chrType='B') and intShopperID=" & rsInput("intShopperID") set rsShopper = gobjConn.execute(strSQL) if rsShopper.eof then s = s & "  System error--unable to retrieve shopper information." else s = s & "  " & rsShopper("vchLastName") & ", " & rsShopper("vchFirstName") & "
" if not IsNull(rsShopper("vchCompany")) then s = s & "  " & rsShopper("vchCompany") & "
" end if if not IsNull(rsShopper("vchAddress1")) then s = s & "  " & rsShopper("vchAddress1") & "
" end if if not IsNull(rsShopper("vchAddress2")) then s = s & "  " & rsShopper("vchAddress2") & "
" end if s = s & "  " & rsShopper("vchCity") & ", " & rsShopper("vchState") & " " & rsShopper("vchZip") & "
" if not IsNull(rsShopper("vchCountry")) then s = s & "  " & rsShopper("vchCountry") & "
" end if if not IsNull(rsShopper("vchDayPhone")) then s = s & "  Day: " & rsShopper("vchDayPhone") & "
" end if if not IsNull(rsShopper("vchNightPhone")) then s = s & "  Night: " & rsShopper("vchNightPhone") & "
" end if if not IsNull(rsShopper("vchFax")) then s = s & "  Fax: " & rsShopper("vchFax") & "
" end if if not IsNull(rsShopper("vchEmail")) then s = s & "  Email: " & rsShopper("vchEmail") & "
" end if end if rsShopper.close set rsShopper = nothing end if s = s & "
" s = s & "
" ' FOOTER s = s & "
" s = s & "" s = s & "" set rsLineItem = GetOrderLineItems_Other(rsInput("intID")) s = s & GetMerchant_DrawOrderCart(rsInput, rsLineItem, false, false, "", "", "", "") rsLineItem.close set rsLineItem = nothing GetInvoiceHTML = s end function '-------------------------------------------- sub SendOrderShipEmail_Other(intOrderID) dim strMessage, strSQL, rsData strSQL = "SELECT O.*, A.vchFirstName + ' ' + A.vchLastName AS A_vchShopperAccount, A.vchEmail AS A_vchEmail, B.vchEmail AS B_vchEmail, S.vchEmail AS S_vchEmail FROM ((" & STR_TABLE_ORDER & " AS O LEFT JOIN " & STR_TABLE_SHOPPER & " AS A ON O.intShopperID = A.intID) LEFT JOIN " & STR_TABLE_SHOPPER & " AS B ON O.intBillShopperID = B.intID) LEFT JOIN " & STR_TABLE_SHOPPER & " AS S ON O.intShipShopperID = S.intID WHERE O.intID=" & intOrderID & " AND O.chrStatus<>'D' AND (A.chrType='A' OR A.chrType IS NULL)" set rsData = gobjConn.execute(strSQL) if not rsData.eof then dim strEmail1, strEmail2, strEmail3 strEmail1 = rsData("A_vchEmail") & "" strEmail2 = rsData("B_vchEmail") & "" strEmail3 = rsData("S_vchEmail") & "" if strEmail1 = strEmail2 then strEmail2 = "" end if if (strEmail1 = strEmail3) or (strEmail2 = strEmail3) then strEmail3 = "" end if if len(rsData("vchShippingNumber") & "") > 0 then strMessage = "SHIPMENT CONFIRMATION - Your order has been shipped. Your shipping tracking number is: " & rsData("vchShippingNumber") else strMessage = "SHIPMENT CONFIRMATION - Your order has been shipped. If you have any questions, please contact our customer service staff at the address or phone number shown above." end if SendInvoiceMail rsData, strMessage, strEmail1, strEmail2, strEmail3 end if rsData.close set rsData = nothing end sub '-------------------------------------------- sub SendOrderEmail_Other(intOrderID, strMessage) dim strSQL, rsData strSQL = "SELECT O.*, A.vchFirstName + ' ' + A.vchLastName AS A_vchShopperAccount, A.vchEmail AS A_vchEmail, B.vchEmail AS B_vchEmail, S.vchEmail AS S_vchEmail FROM ((" & STR_TABLE_ORDER & " AS O LEFT JOIN " & STR_TABLE_SHOPPER & " AS A ON O.intShopperID = A.intID) LEFT JOIN " & STR_TABLE_SHOPPER & " AS B ON O.intBillShopperID = B.intID) LEFT JOIN " & STR_TABLE_SHOPPER & " AS S ON O.intShipShopperID = S.intID WHERE O.intID=" & intOrderID & " AND O.chrStatus<>'D' AND (A.chrType='A' OR A.chrType IS NULL)" set rsData = gobjConn.execute(strSQL) if not rsData.eof then dim strEmail1, strEmail2, strEmail3 strEmail1 = rsData("A_vchEmail") & "" strEmail2 = rsData("B_vchEmail") & "" strEmail3 = rsData("S_vchEmail") & "" if strEmail1 = strEmail2 then strEmail2 = "" end if if (strEmail1 = strEmail3) or (strEmail2 = strEmail3) then strEmail3 = "" end if SendInvoiceMail rsData, strMessage, strEmail1, strEmail2, strEmail3 end if rsData.close set rsData = nothing end sub '-------------------------------------------- function GetOrderShippingPrice_Other(intOrderID) GetOrderShippingPrice_Other = 0 dim strSQL, rsTemp strSQL = "SELECT mnyShipAmount FROM " & STR_TABLE_ORDER & " WHERE intID=" & intOrderID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then if not IsNull(rsTemp("mnyShipAmount")) then GetOrderShippingPrice_Other = rsTemp("mnyShipAmount") end if end if rsTemp.close set rsTemp = nothing end function '-------------------------------------------- function GetOrderShippingZone(mnySubtotal, strCountry, strState, intShipOption) dim mnyShipPrice mnySubtotal = 0 strCountry = "" intShipOption = 0 if gintOrderID > 0 then GetOrderShippingZone = GetOrderShippingZone_Other(gintOrderID, mnySubtotal, strCountry, strState, intShipOption, mnyShipPrice) end if end function '-------------------------------------------- function GetOrderShippingZone_Other(intOrderID, mnySubtotal, strCountry, strState, intShipOption, mnyShipPrice) 'Seperate subtotal amounts dim strSQL, rsTemp mnySubtotal = 0 strCountry = "" strState = "" intShipOption = 0 strSQL = "SELECT ISNULL(mnyTaxSubtotal,0) + ISNULL(mnyNonTaxSubtotal,0) - ISNULL(mnyShipAmount,0) AS mnySubTotal, O.mnyShipAmount, S.vchCountry, s.vchState, O.intShipOption" strSQL = strSQL & " FROM " & STR_TABLE_ORDER & " AS O, " & STR_TABLE_SHOPPER & " AS S" strSQL = stRSQL & " WHERE O.intID=" & intOrderID & " AND O.intShipShopperID = S.intID" set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then mnySubtotal = rsTemp("mnySubTotal") strCountry = rsTemp("vchCountry") strState = rsTemp("vchState") intShipOption = rsTemp("intShipOption") mnyShipPrice = rsTemp("mnyShipAmount") end if rsTemp.close set rsTemp = nothing end function '-------------------------------------------- sub SetOrderTaxExempt(intTaxZone) if gintOrderID > 0 then SetOrderTaxExempt_Other gintOrderID, 0, 0 end if end sub '-------------------------------------------- sub SetOrderTaxExempt_Other(intOrderID, intTaxZone, mnyTaxAmount) dim dctSaveList, fltTaxRate fltTaxRate = 0.0 set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "#intTaxZone", intTaxZone dctSaveList.Add "#fltTaxRate", fltTaxRate dctSaveList.Add "#mnyTaxAmount", mnyTaxAmount SaveDataRecord STR_TABLE_ORDER, Request, intOrderID, dctSaveList RecalcOrder_Other intOrderID end sub '-------------------------------------------- sub SetOrderShipOption(intShipOption) if gintOrderID > 0 then SetOrderShipOption_Other gintOrderID, intShipOption, 0 end if end sub '-------------------------------------------- sub SetOrderShipOption_Other(intOrderID, intShipOption, mnyShipPrice) dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "#intShipOption", intShipOption if (intShipOption > 0 and mnyShipPrice > 0) then dctSaveList.Add "#mnyShipAmount", mnyShipPrice elseif (intShipOption = -1) then dctSaveList.Add "#mnyShipAmount", mnyShipPrice end if SaveDataRecord STR_TABLE_ORDER, Request, intOrderID, dctSaveList RecalcOrder_Other intOrderID end sub '-------------------------------------------- function GetOrderShipOption_Other(intOrderID) dim strSQL, rsTemp strSQL = "SELECT ISNULL(intShipOption,-1) as intShipOption FROM " & STR_TABLE_ORDER & " WHERE intID=" & intOrderID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then GetOrderShipOption_Other = rsTemp("intShipOption") else GetOrderShipOption_Other = -1 end if rsTemp.close set rsTemp = nothing end function '-------------------------------------------- ' old method - looks ups receive email from user table sub SendMerchantEmail(strSubject, strMessage) dim strSQL, rsTemp strSQL = "SELECT vchReceiveEmail FROM " & STR_TABLE_USER & " WHERE chrStatus='A' AND vchReceiveEmail IS NOT NULL" set rsTemp = gobjConn.execute(strSQL) while not rsTemp.eof SendMail "dde@americanwebservices.com", rsTemp("vchReceiveEmail"), "", "", strSubject, strMessage 'webuser@americanwebservices.com rsTemp.MoveNext wend rsTemp.close set rsTemp = nothing end sub '-------------------------------------------- ' new method - link merchant brandid to inventory brandid by joining the inventory items to the order line items. sub SendMerchantEmailX(strSubject, strMessage) dim strSQL, rsTemp strSQL = "SELECT O.intOrderID, U.intBrand, U.vchReceiveEmail" strSQL = strSQL & " FROM " & STR_TABLE_LINEITEM & " AS O, " & STR_TABLE_INVENTORY & " AS I, " & STR_TABLE_USER & " AS U" strSQL = strSQL & " WHERE (O.chrStatus='A') AND (O.intOrderID = '" & gintOrderID & "')" strSQL = strSQL & " AND (I.chrStatus='A') AND (I.intID = O.intInvID)" if strSubject <> "Order Notification" then ' order has NOT been approved - send email to admin only... strSQL = strSQL & " AND (U.chrStatus='A') AND (IsNull(U.intBrand,0) = 0)" else ' order has been appoved - send email to admin and merchants... strSQL = strSQL & " AND (U.chrStatus='A') AND ((U.intBrand = I.intBrand) OR (IsNull(U.intBrand,0) = 0))" end if strSQL = strSQL & " AND (IsNull(U.vchReceiveEmail,'') <> '')" strSQL = strSQL & " GROUP BY O.intOrderID, U.intBrand, U.vchReceiveEmail" ' response.write strSQL & "
" set rsTemp = gobjConn.execute(strSQL) dim strTo, strNewMessage, n strNewMessage = strMessage strTo = "" n = 0 while not rsTemp.eof if IsValid(rsTemp("vchReceiveEmail")&"") then strTo = strTo & iif(n > 0, ", ", " ") & rsTemp("vchReceiveEmail") & "" n = n + 1 end if rsTemp.MoveNext wend rsTemp.close set rsTemp = nothing strNewMessage = strNewMessage & vbcrlf & "Message sent to: " & n & " users." & vbcrlf if lcase(strServerHost) = "awsdev" then ' running from internal strNewMessage = strNewMessage & strTo & vbcrlf SendMail STR_MERCHANT_CS_EMAIL, "dde@americanwebservices.com", "", "", strSubject, strNewMessage else if IsValid(strTo) then SendMail STR_MERCHANT_CS_EMAIL, strTo, "", "", strSubject, strNewMessage end if end if end sub ' 5dec2000 - ssutterfield: added shipping price matrix functions function MakeShipPriceMatrixTable(aryShipBaseMatrix) dim s, a, x s = "" x = ubound(aryShipBaseMatrix) - 1 for a = 0 to x s = s & "" s = s & "" next s = s & "" s = s & "" s = s & "
" & font(1) & "Up to " & FormatCurrency(aryShipBaseMatrix(a,0),2) & "...  " & font(1) & FormatCurrency(aryShipBaseMatrix(a,1),2) & "
" & font(1) & "Over " & FormatCurrency(aryShipBaseMatrix(x,0),2) & "...  " & font(1) & FormatNumber(aryShipBaseMatrix(x + 1,0) * 100,0) & "% of subtotal
" MakeShipPriceMatrixTable = s end function '-------------------------------------------- function GetShipPriceMatrixTable(mnySubTotal, aryShipBaseMatrix, mnyBaseShipping) redim aryShipBaseMatrix(6,1) ' price matrix for base shipping: ' (n,0) = upper-limit for sub-total : (n,1) = shipping price for this level ' last item in matrix: (n,0) = percentage against sub-total to determine shipping price aryShipBaseMatrix(0,0) = 25.00 : aryShipBaseMatrix(0,1) = 7.97 aryShipBaseMatrix(1,0) = 50.00 : aryShipBaseMatrix(1,1) = 9.97 aryShipBaseMatrix(2,0) = 75.00 : aryShipBaseMatrix(2,1) = 14.97 aryShipBaseMatrix(3,0) = 100.00 : aryShipBaseMatrix(3,1) = 19.97 aryShipBaseMatrix(4,0) = 150.00 : aryShipBaseMatrix(4,1) = 24.97 aryShipBaseMatrix(5,0) = 200.00 : aryShipBaseMatrix(5,1) = 29.97 aryShipBaseMatrix(6,0) = 0.15 : aryShipBaseMatrix(6,1) = -1 ' aryShipBaseMatrix(7,0) = 0.0 : aryShipBaseMatrix(6,1) = -1 dim c, x x = ubound(aryShipBaseMatrix) - 1 c = 0 mnyBaseShipping = -1 while (c <= x) and (mnyBaseShipping = -1) if mnySubTotal < aryShipBaseMatrix(c,0) then mnyBaseShipping = aryShipBaseMatrix(c,1) end if c = c + 1 wend if (mnyBaseShipping = -1) then mnyBaseShipping = Fix(mnySubTotal * aryShipBaseMatrix(c,0) * 100) / 100 end if GetShipPriceMatrixTable = aryShipBaseMatrix end function '-------------------------------------------- sub GetShipPriceMatrix(intShipOption, mnySubTotal, aryShipBaseMatrix, aryShipUPS_Matrix, aryShipOption, mnyBaseShipping) ' aryShipBaseMatrix = GetShipPriceMatrixTable(mnySubTotal, aryShipBaseMatrix, mnyBaseShipping) redim aryShipOption(6,2) redim aryShipUPS_Matrix(3,1) ' shipping option matrix: ' (n,0) = shipping option value ' (n,1) = shipping option label ' (n,2) = shipping price dim intShipWeight intShipWeight = PollShippingWeightByOrder(gintOrderID) aryShipUPS_Matrix = PollShipPriceMatrixUPS(intShipOption, aryShipUPS_Matrix, intShipWeight) dim x, xCnt, maxOption, maxX maxOption = ubound(aryShipUPS_Matrix) maxX = ubound(aryShipOption) aryShipOption(0,0) = 1 aryShipOption(0,1) = "US Priority Mail (2-4 day average)
" 'US Postal Service aryShipOption(0,2) = PollShippingPrice(1, intShipWeight) ' new UPS shipping options for xCnt = 0 to maxOption x = xCnt + 1 if x <= maxX then aryShipOption(x,0) = iif((aryShipUPS_Matrix(xCnt,1)>0),x+1,-1) aryShipOption(x,1) = aryShipUPS_Matrix(xCnt,0)&"
" aryShipOption(x,2) = -1'aryShipUPS_Matrix(xCnt,1) end if next aryShipOption(xCnt + 1,0) = xCnt + 2 aryShipOption(xCnt + 1,1) = "FedEx
" 'US Postal Service aryShipOption(xCnt + 1,2) = PollShippingPrice(xCnt + 1, intShipWeight) aryShipOption(xCnt + 2,0) =xCnt + 3 aryShipOption(xCnt + 2,1) = "DHL
" 'US Postal Service aryShipOption(xCnt + 2,2) = PollShippingPrice(xCnt + 2, intShipWeight) ' old UPS shipping options ' aryShipOption(1,0) = -1 '2 ' aryShipOption(1,1) = "UPS Ground
" ' aryShipOption(1,2) = PollShippingPrice(2, intWeight) ' aryShipOption(2,0) = -1 '3 ' aryShipOption(2,1) = "UPS 2nd Day Air
" ' aryShipOption(2,2) = PollShippingPrice(3, intWeight) ' aryShipOption(3,0) = -1 '4 ' aryShipOption(3,1) = "UPS Overnight
" ' aryShipOption(3,2) = PollShippingPrice(4, intWeight) ' dim x ' for x = 1 to 3 ' if aryShipOption(x,2) > 0 then ' aryShipOption(x,0) = x+1 ' end if ' next end sub sub GetShipPriceMatrix_Other(intOrderID, intShipOption, mnySubTotal, aryShipBaseMatrix, aryShipUPS_Matrix, aryShipOption, mnyBaseShipping) redim aryShipOption(4,2) redim aryShipUPS_Matrix(3,1) ' shipping option matrix: ' (n,0) = shipping option value ' (n,1) = shipping option label ' (n,2) = shipping price dim intWeight intWeight = PollShippingWeightByOrder(intOrderID) aryShipUPS_Matrix = PollShipPriceMatrixUPS(intShipOption, aryShipUPS_Matrix, intWeight) dim x, xCnt, maxOption, maxX maxOption = ubound(aryShipUPS_Matrix) maxX = ubound(aryShipOption) aryShipOption(0,0) = 1 aryShipOption(0,1) = "US Priority Mail (2-4 day average)
" 'US Postal Service aryShipOption(0,2) = PollShippingPriceByOrder(intOrderID,1,intWeight) aryShipOption(1,0) = -1 '2 ' new UPS shipping options for xCnt = 0 to maxOption x = xCnt + 1 if x <= maxX then aryShipOption(x,0) = iif((aryShipUPS_Matrix(xCnt,1)>0),x+1,-1) aryShipOption(x,1) = aryShipUPS_Matrix(xCnt,0)&"
" aryShipOption(x,2) = aryShipUPS_Matrix(xCnt,1) end if next end sub '-------------------------------------------- function PollShippingWeightByOrder (intOrderID) dim strSQL, rsWeight, intWeight strSQL = "SELECT ISNULL(SUM(ISNULL(I.fltShipWeight * L.intQuantity, 0)), 0) AS fltShipWeight FROM " & STR_TABLE_LINEITEM & " L, " & STR_TABLE_INVENTORY & " I " strSQL = strSQL & " WHERE (L.chrStatus='A') AND (L.intOrderID=" & intOrderID &") AND (I.intID=L.intInvID)" ' if intShipOption = 1 then ' don't include free shipping items in total if ground ' strSQL = strSQL & " AND chrFreeShip<>'Y'" ' end if ' response.write strSQL & "
" set rsWeight = gobjConn.execute(strSQL) intWeight = rsWeight("fltShipWeight") if intWeight > 0 then intWeight = cDbl(intWeight) + INT_PACKAGE_WEIGHT '0.5 lbs for box/envelope weight end if rsWeight.close set rsWeight = nothing ' response.write "intOrderID = " & intOrderID & "  " ' response.write "intWeight = " & intWeight & "
" if intWeight > 250 then intWeight = 250 PollShippingWeightByOrder = intWeight end function '-------------------------------------------- function PollShipPriceMatrixUPS (intShipOption, aryShipUPS_Matrix, intShipWeight) redim aryShipUPS_Matrix(3,1) ' Build UPS Shipping Price Matrix PollShipPriceMatrixUPS = UPS_Trans_Matrix(gintOrderID, intShipOption, aryShipUPS_Matrix, intShipWeight) end function '-------------------------------------------- function PollShipPriceMatrixUPS_Other (intOrderId, intShipOption, aryShipUPS_Matrix, intWeight) redim aryShipUPS_Matrix(3,1) ' Build UPS Shipping Price Matrix PollShipPriceMatrixUPS_Other = UPS_Trans_Matrix(intOrderId, intShipOption, aryShipUPS_Matrix, intWeight) end function '-------------------------------------------- ' ==[ PollShippingPrice ]=========================================== ' Returns the shipping price for current open order, depending on ' shipping option selected ' Arguments: ' intShipOption - 1: UPS Ground ' 2: UPS Second Day ' 3: UPS Next Day ' Return Value - shipping price ' ============================================================== function PollShippingPrice (intShipOption, intWeight) PollShippingPrice = PollShippingPriceByOrder(gintOrderID, intShipOption, intWeight) end function function PollShippingPrice_Other (intOrderID, intShipOption, intWeight) PollShippingPrice_Other = PollShippingPriceByOrder(intOrderID, intShipOption, intWeight) end function '-------------------------------------------- ' ==[ PollShippingPriceByOrder ]=========================================== ' Returns the shipping price for a given order, depending on shipping ' option selected ' Arguments: ' intOrderID - ID of order ' intShipOption - 1: UPS Ground ' 2: UPS Second Day ' 3: UPS Next Day ' Return Value - shipping price ' ============================================================== function PollShippingPriceByOrder (intOrderID, intShipOption, intWeight) dim fltPrice if IsNumeric(intWeight) then intWeight = cDbl(intWeight) else intWeight = 0 end if if intWeight = 0 then intWeight = PollShippingWeightByOrder(intOrderID) + INT_PACKAGE_WEIGHT end if if intWeight < 1 then intWeight = 1 end if ' response.write "intOrderID = " & intOrderID & "  " ' response.write "intShipOption = " & intShipOption & "  " ' response.write "intWeight = " & intWeight & "
" select case intShipOption case 1 dim intOrderShipID intOrderShipID = GetOrderBillID_Other(intOrderID,true) dim strSQL, rsTemp, intZone, intRate, strZip dim strLabel, strEmail, strFirstName, strLastName, strCompany, strAddress1, strAddress2, strCity, strState, strCountry, strDayPhone, strNightPhone, strFax, intTaxZone GetOrderAddress_Other intOrderID, true, intOrderShipID, strLabel, strEmail, strFirstName, strLastName, strCompany, strAddress1, strAddress2, strCity, strState, strZip, strCountry, strDayPhone, strNightPhone, strFax, intTaxZone ' response.write "Zip Code = " & strZip & "
" ' US Priority Mail (2-4 day average) - US Postal Service if IsNumeric(strZip) then strZip = Left(strZip,3) strSQL = "SELECT * " strSQL = strSQL & " FROM " & STR_TABLE_SHIPZONE & " WHERE intHigh >= " & strZip & " AND intLow <= " & strZip set rsTemp = ConnOpenRS(strSQL) if not rsTemp.EOF then intZone = rsTemp("intZone") end if rsTemp.close set rsTemp = nothing ' response.write "intZone = " & intZone & "
" strSQL = "SELECT * " strSQL = strSQL & " FROM " & STR_TABLE_SHIPRATE & " WHERE intWeight = " & round(intWeight) set rsTemp = ConnOpenRS(strSQL) If not rsTemp.EOF then select case intZone case 1, 2, 3 fltPrice = rsTemp("mnyZone1") case 4 fltPrice = rsTemp("mnyZone4") case 5 fltPrice = rsTemp("mnyZone5") case 6 fltPrice = rsTemp("mnyZone6") case 7 fltPrice = rsTemp("mnyZone7") case 8 fltPrice = rsTemp("mnyZone8") case else fltPrice = rsTemp("mnyZone8") end select else ' no rates found for this weight fltPrice = 0 end if 'fltPrice = fltPrice + .45 ' USPS Shipping Confirmation fltPrice = fltPrice 'changed by Deb rsTemp.close set rsTemp = nothing else fltPrice = 0 end if case 2, 3, 4 ' 2 - UPS Ground ' 3 - UPS 2nd Day Air ' 4 - UPS Overnight if IsNumeric(intShipOption) then intShipOption = CLng(intShipOption) if intShipOption < 1 then intShipOption = 1 end if else intShipOption = 1 end if if IsNumeric(intWeight) then intWeight = cDbl(intWeight) if intWeight < 1 then intWeight = 1 end if else intWeight = 1 end if fltPrice = UPS_Trans_Run(intOrderID, intShipOption, intWeight) if fltPrice > 0 then fltPrice = fltPrice + INT_UPS_SHIP_CONFIRM_PRICE 'ADD $0 UPS Shipping Confirmation fltPrice = fltPrice + INT_UPS_HANDLING_FEE 'ADD $2 Handling Fee to all UPS orders end if case 5 'FedEx strSql = "SELECT TOP 1 [FedEx Express Saver] FROM EXSWest_FedEx WHERE Weight>=" & round(intWeight) & " Order BY Weight" set rsTemp = ConnOpenRS(strSQL) If not rsTemp.EOF then fltPrice = CDBL(rsTemp(0)&"") else fltPrice = 0 end if case 6 '$0.68 $0.79 $0.99 $1.39 $2.10 $2.26 $2.34 dim arrRatePerPound arrRatePerPound = Split("0.68 ,0.79 ,0.99 ,1.39 ,2.10 ,2.26 ,2.34"," ,") fltPrice = (intWeight * arrRatePerPound(cint(intZone))) + 3.12 case else fltPrice = 0 end select ' response.write "Shipping: " & fltPrice & "
" if fltPrice > 0 then fltPrice = fltPrice + INT_HANDLING_FEE ' ADD $0 Handling Fee to all orders end if PollShippingPriceByOrder = fltPrice end function '-------------------------------------------- function GetShipPriceByOption(mnySubTotal, intShipOption) dim c, x, aryShipBaseMatrix, aryShipUPS_Matrix, aryShipOption, mnyBaseShipping GetShipPriceMatrix intShipOption, mnySubTotal, aryShipBaseMatrix, aryShipUPS_Matrix, aryShipOption, mnyBaseShipping x = ubound(aryShipOption) for c = 0 to x if aryShipOption(c,0) = intShipOption then GetShipPriceByOption = aryShipOption(c,2) if GetShipPriceByOption > 0 then if instr(aryShipOption(c,1),"UPS") > 0 then GetShipPriceByOption = GetShipPriceByOption + INT_UPS_SHIP_CONFIRM_PRICE 'ADD $0 UPS Shipping Confirmation GetShipPriceByOption = GetShipPriceByOption + INT_UPS_HANDLING_FEE 'ADD $2 Handling Fee to all UPS orders end if GetShipPriceByOption = GetShipPriceByOption + INT_HANDLING_FEE ' ADD $0 Handling Fee to all orders end if exit function end if next GetShipPriceByOption = 0 end function '-------------------------------------------- '=============================================================== ' GetOptionDct ' Desc: Parse OptionList string to form dictionary of text,price ' Input: strOptionList -OptionList string ' Output: dictionary key="option text" value="option price" '=============================================================== function GetOptionDct(strOptionList) dim aryOptions, intOptions, vOption, intInStr, intInStrRev set GetOptionDct = Server.CreateObject("Scripting.Dictionary") if IsValid(strOptionList) then aryOptions = split(strOptionList, ",") intOptions = ubound(aryOptions) for vOption=0 to intOptions if InStr(aryOptions(vOption), "=$") <> 0 then 'Option Validation intInStr = InStr(aryOptions(vOption), "=$") intInStrRev = InStrRev(aryOptions(vOption), "=$") GetOptionDct.Add Left( aryOptions(vOption), intInStr-1 ), iif( intInStrRev <> len(aryOptions(vOption)), Right(aryOptions(vOption), len(aryOptions(vOption))-intInStrRev-1), "" ) end if next end if end function '--------------------------------------------------------------- '=============================================================== ' GetOptionName ' Desc: Validate The Option and return its name ' ' Input: strOptionChoice -Desired option ' intID -ID of Item ' strOptionList -Option List to search ' ' Output: Item Name & option or Item name '=============================================================== function GetOptionName(strOptionChoice, intID) dim strSQL, rsTemp dim dctOptions, vKey strSQL = "SELECT vchItemName, vchOptionList1 " strSQL = strSQL & "FROM " & STR_TABLE_INVENTORY & " " strSQL = strSQL & "WHERE (intId=" & intID & ") " set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then set dctOptions = GetOptionDct( rsTemp("vchOptionList1") ) for each vKey in dctOptions.Keys() if strOptionChoice = vKey then GetOptionName = rsTemp("vchItemName") & " (" & vKey & ")" rsTemp.close set rsTemp = nothing exit function end if next GetOptionName = rsTemp("vchItemName") rsTemp.close set rsTemp = nothing else GetOptionName = "" end if end function '=============================================================== ' GetOptionPrice ' Desc: Get an items optionList price if it exists ' ' Inputs: strOptionList -Items OptionList1 ' strOptionChoice -Shopper's Desired Option ' intItemPrice -Items non/default Option Price ' ' Outputs: Total Price in Currency for this LineItem '=============================================================== function GetOptionPrice(strOptionList, strOptionChoice, intItemPrice) dim dctOptionList, vKey set dctOptionList = GetOptionDct(strOptionList) for each vKey in dctOptionList if strOptionChoice = vKey then GetOptionPrice = CCur( iif(IsValid(dctOptionList(vKey)), dctOptionList(vKey), intItemPrice) ) exit function end if next GetOptionPrice = CCur(intItemPrice) end function '--------------------------------------------------------------- '=============================================================== ' IsValid ' Desc: Determines if a variant is "", " ", NULL, (-) or 0 ' Input: vItem ' Output: Boolean to validity '=============================================================== Function IsValid(vItem) If IsNull(vItem) Or IsEmpty(vItem) Or vItem = "" Or vItem = " " Then IsValid = False Else If IsNumeric(vItem) Then IsValid = iif(vItem > 0, True, False) Else IsValid = True End if End If End Function '--------------------------------------------------------------- '-------------------------------------------- function GetOrderGiftMessage() GetOrderGiftMessage = GetOrderGiftMessage_Other(gintOrderID) end function function GetOrderGiftMessage_Other(intOrderID) dim strSQL, rsTemp strSQL = "SELECT txtGiftMessage FROM " & STR_TABLE_ORDER & " WHERE intID=" & intOrderID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then GetOrderGiftMessage_Other = rsTemp("txtGiftMessage") & "" end if rsTemp.close set rsTemp = nothing end function '-------------------------------------------- sub SetOrderGiftMessage(strMsg) SetOrderGiftMessage_Other gintOrderID, strMsg end sub '-------------------------------------------- sub SetOrderGiftMessage_Other(intOrderID, byVal strMsg) if intOrderID > 0 then dim strSQL if trim(strMsg & "") = "" then strMsg = "none" end if strSQL = "UPDATE " & STR_TABLE_ORDER & " SET txtGiftMessage='" & SQLEncode(strMsg) & "' WHERE intID=" & intOrderID gobjConn.execute(strSQL) end if end sub '-------------------------------------------- sub UpdateOrderGiftMessage(strGiftMessage) ' updates the gift message of the current order UpdateOrderGiftMessage_Other gintOrderID, strGiftMessage ' gstrGiftMessage = strMessage end sub '-------------------------------------------- sub UpdateOrderGiftMessage_Other(intOrderID, strGiftMessage) if intOrderID > 0 and strGiftMessage <> "" then dim dctSaveList set dctSaveList = Server.CreateObject("Scripting.Dictionary") dctSaveList.Add "@dtmUpdated", "GETDATE()" dctSaveList.Add "vchUpdatedByUser", "pub" dctSaveList.Add "vchUpdatedByIP", gstrUserIP dctSaveList.Add "txtGiftMessage", strGiftMessage SaveDataRecord STR_TABLE_ORDER, Request, intOrderID, dctSaveList end if end sub '-------------------------------------------- sub PrepareSpecialAdd(intForceShipMethod, blnForceSoloItem) PrepareSpecialAdd_Other intOrderID, intForceShipMethod, blnForceSoloItem end sub '-------------------------------------------- sub PrepareSpecialAdd_Other(intOrderID, intForceShipMethod, blnForceSoloItem) dim rsItem, strSQL, strDelList strDelList = "" strSQL = "SELECT intID, intForceShipMethod, chrForceSoloItem FROM " & STR_TABLE_LINEITEM & " WHERE intOrderID=" & intOrderID & " AND chrStatus<>'D'" set rsItem = gobjConn.execute(strSQL) while not rsItem.eof if (intForceShipMethod & "" <> "") and (rsItem("intForceShipMethod") & "" <> "") and (intForceShipMethod & "" <> rsItem("intForceShipMethod") & "") then strDelList = strDelList & rsItem("intID") & "," elseif blnForceSoloItem then strDelList = strDelList & rsItem("intID") & "," elseif rsItem("chrForceSoloItem") = "Y" then strDelList = strDelList & rsItem("intID") & "," end if rsItem.MoveNext wend rsItem.close set rsItem = nothing if strDelList <> "" then strSQL = "UPDATE " & STR_TABLE_LINEITEM & " SET chrStatus='D' WHERE intID IN (" & left(strDelList, len(strDelList) - 1) & ")" gobjConn.execute(strSQL) end if end sub '-------------------------------------------- function CanAddItem(intID) if gintOrderID > 0 then CanAddItem = CanAddItem_Other(gintOrderID, intID) else CanAddItem = true end if end function '-------------------------------------------- function CanAddItem_Other(intOrderID, intID) dim strSQL, rsTemp, intForceShipMethod, chrForceSoloItem strSQL = "SELECT intForceShipMethod, chrForceSoloItem FROM " & STR_TABLE_INVENTORY & " WHERE intID=" & intID set rsTemp = gobjConn.execute(strSQL) if not rsTemp.eof then intForceShipMethod = rsTemp("intForceShipMethod") chrForceSoloItem = rsTemp("chrForceSoloItem") rsTemp.close set rsTemp = nothing CanAddItem_Other = CanAddItemSpecial_Other(intOrderID, intForceShipMethod, chrForceSoloItem) else CanAddItem_Other = true rsTemp.close set rsTemp = nothing end if end function '-------------------------------------------- function CanAddItemSpecial_Other(intOrderID, intForceShipMethod, chrForceSoloItem) ' return true if item can be added without conflict with other items ordered ' otherwise return false dim strSQL, rsTemp CanAddItemSpecial_Other = true if (chrForceSoloItem = "Y") then ' item must be ordered separately from all other items ' if there are any other items in this order, return false strSQL = "SELECT COUNT(*) AS intItemCount FROM " & STR_TABLE_LINEITEM & " WHERE intOrderID=" & intOrderID & " AND chrStatus<>'D'" set rsTemp = gobjConn.execute(strSQL) if rsTemp("intItemCount") > 0 then CanAddItemSpecial_Other = false end if rsTemp.close set rsTemp = nothing if CanAddItemSpecial_Other = false then exit function end if end if if intForceShipMethod & "" <> "" then ' item can not be ordered along with any other item that requires a forced shipping method ' other than this method strSQL = "SELECT intForceShipMethod FROM " & STR_TABLE_LINEITEM & " WHERE intOrderID=" & intOrderID & " AND chrStatus<>'D' AND intForceShipMethod IS NOT NULL" set rsTemp = gobjConn.execute(strSQL) while not rsTemp.eof if rsTemp("intForceShipMethod") <> intForceShipMethod then CanAddItemSpecial_Other = false rsTemp.close set rsTemp = nothing exit function end if rsTemp.MoveNext wend rsTemp.close set rsTemp = nothing end if ' check existing items in order to see if any are marked as "must be ordered separately" strSQL = "SELECT chrForceSoloItem FROM " & STR_TABLE_LINEITEM & " WHERE intOrderID=" & intOrderID & " AND chrStatus<>'D' AND chrForceSoloItem='Y'" set rsTemp = gobjConn.execute(strSQL) CanAddItemSpecial_Other = rsTemp.eof rsTemp.close set rsTemp = nothing end function '-------------------------------------------- sub SetOrderDiscount_Other(intOrderID, byVal intRefID, strRefName, fltRefDiscount) if intOrderID > 0 then if IsNumeric(intRefID) then intRefID = CLng(intRefID) if intRefID > 0 then dim strSQL strSQL = "UPDATE " & STR_TABLE_ORDER & " SET intReferalID=" & intRefID & ", vchReferalName='" & SQLEncode(strRefName & "") & "', fltReferalDiscount=" & fltRefDiscount strSQL = strSQL & " WHERE intID=" & intOrderID gobjConn.execute(strSQL) RecalcOrder end if end if end if end sub '-------------------------------------------- function GetPageHeader (intID) select case FindTopFolder(intID) case INT_GOCART_RETAIL GetPageHeader = "Retail" case INT_GOCART_WHOLESALE GetPageHeader = "Wholesale" case INT_GOCART_INGREDIENTS GetPageHeader = "Ingredients" case else GetPageHeader = Request("type") if GetPageHeader = "" then GetPageHeader = "Retail" end if end select end function '-------------------------------------------- function FindTopFolder (ByVal intID) dim rsParent, intParentID set rsParent = ConnOpenRS("SELECT intParentID FROM " & STR_TABLE_INVENTORY & " WHERE intID=" & intID) if intID = INT_GOCART_WHOLESALE then FindTopFolder = INT_GOCART_WHOLESALE else if rsParent.EOF then FindTopFolder = iif(strPageType="Wholesale",INT_GOCART_WHOLESALE,0) elseif rsParent("intParentID") = 0 then FindTopFolder = intID elseif rsParent("intParentID") = INT_GOCART_WHOLESALE then FindTopFolder = intID else FindTopFolder = FindTopFolder(rsParent("intParentID")) end if end if rsParent.close set rsParent = nothing end function function CloneOrder(intOrderID) dim strOrderSQL, rsOrderData strOrderSQL = "INSERT INTO " & STR_TABLE_ORDER & "(" strOrderSQL = strOrderSQL & "chrType, " strOrderSQL = strOrderSQL & "chrStatus, " strOrderSQL = strOrderSQL & "dtmCreated, " strOrderSQL = strOrderSQL & "dtmUpdated, " strOrderSQL = strOrderSQL & "vchCreatedByUser, " strOrderSQL = strOrderSQL & "vchUpdatedByUser, " strOrderSQL = strOrderSQL & "vchCreatedByIP, " strOrderSQL = strOrderSQL & "vchUpdatedByIP, " strOrderSQL = strOrderSQL & "vchShippingNumber, " strOrderSQL = strOrderSQL & "vchShopperIP, " strOrderSQL = strOrderSQL & "vchShopperBrowser, " strOrderSQL = strOrderSQL & "dtmSubmitted, " strOrderSQL = strOrderSQL & "chrModifyFlag, " strOrderSQL = strOrderSQL & "chrPaymentMethod, " strOrderSQL = strOrderSQL & "vchPaymentCardType, " strOrderSQL = strOrderSQL & "vchPaymentCardName, " strOrderSQL = strOrderSQL & "vchPaymentCardNumber, " strOrderSQL = strOrderSQL & "vchPaymentCardExtended, " strOrderSQL = strOrderSQL & "chrPaymentCardExpMonth, " strOrderSQL = strOrderSQL & "chrPaymentCardExpYear, " strOrderSQL = strOrderSQL & "vchPaymentBankName, " strOrderSQL = strOrderSQL & "vchPaymentRtnNumber, " strOrderSQL = strOrderSQL & "vchPaymentCheckNumber, " strOrderSQL = strOrderSQL & "vchPaymentDLNumber, " strOrderSQL = strOrderSQL & "vchPaymentDLState, " strOrderSQL = strOrderSQL & "chrPaymentAcctType, " strOrderSQL = strOrderSQL & "vchPaymentAcctNumber, " strOrderSQL = strOrderSQL & "intShopperID, " strOrderSQL = strOrderSQL & "intBillShopperID, " strOrderSQL = strOrderSQL & "intShipShopperID, " strOrderSQL = strOrderSQL & "intTaxZone, " strOrderSQL = strOrderSQL & "mnyNonTaxSubtotal, " strOrderSQL = strOrderSQL & "mnyTaxSubtotal, " strOrderSQL = strOrderSQL & "fltTaxRate, " strOrderSQL = strOrderSQL & "mnyTaxAmount, " strOrderSQL = strOrderSQL & "mnyShipAmount, " strOrderSQL = strOrderSQL & "chrShipTaxFlag, " strOrderSQL = strOrderSQL & "mnyGrandTotal, " strOrderSQL = strOrderSQL & "intShipOption, " strOrderSQL = strOrderSQL & "txtGiftMessage) " strOrderSQL = strOrderSQL & " SELECT " strOrderSQL = strOrderSQL & "chrType, " strOrderSQL = strOrderSQL & "chrStatus, " strOrderSQL = strOrderSQL & "dtmCreated, " strOrderSQL = strOrderSQL & "dtmUpdated, " strOrderSQL = strOrderSQL & "vchCreatedByUser, " strOrderSQL = strOrderSQL & "vchUpdatedByUser, " strOrderSQL = strOrderSQL & "vchCreatedByIP, " strOrderSQL = strOrderSQL & "vchUpdatedByIP, " strOrderSQL = strOrderSQL & "vchShippingNumber, " strOrderSQL = strOrderSQL & "vchShopperIP, " strOrderSQL = strOrderSQL & "vchShopperBrowser, " strOrderSQL = strOrderSQL & "dtmSubmitted, " strOrderSQL = strOrderSQL & "chrModifyFlag, " strOrderSQL = strOrderSQL & "chrPaymentMethod, " strOrderSQL = strOrderSQL & "vchPaymentCardType, " strOrderSQL = strOrderSQL & "vchPaymentCardName, " strOrderSQL = strOrderSQL & "vchPaymentCardNumber, " strOrderSQL = strOrderSQL & "vchPaymentCardExtended, " strOrderSQL = strOrderSQL & "chrPaymentCardExpMonth, " strOrderSQL = strOrderSQL & "chrPaymentCardExpYear, " strOrderSQL = strOrderSQL & "vchPaymentBankName, " strOrderSQL = strOrderSQL & "vchPaymentRtnNumber, " strOrderSQL = strOrderSQL & "vchPaymentCheckNumber, " strOrderSQL = strOrderSQL & "vchPaymentDLNumber, " strOrderSQL = strOrderSQL & "vchPaymentDLState, " strOrderSQL = strOrderSQL & "chrPaymentAcctType, " strOrderSQL = strOrderSQL & "vchPaymentAcctNumber, " strOrderSQL = strOrderSQL & "intShopperID, " strOrderSQL = strOrderSQL & "intBillShopperID, " strOrderSQL = strOrderSQL & "intShipShopperID, " strOrderSQL = strOrderSQL & "intTaxZone, " strOrderSQL = strOrderSQL & "mnyNonTaxSubtotal, " strOrderSQL = strOrderSQL & "mnyTaxSubtotal, " strOrderSQL = strOrderSQL & "fltTaxRate, " strOrderSQL = strOrderSQL & "mnyTaxAmount, " strOrderSQL = strOrderSQL & "mnyShipAmount, " strOrderSQL = strOrderSQL & "chrShipTaxFlag, " strOrderSQL = strOrderSQL & "mnyGrandTotal, " strOrderSQL = strOrderSQL & "intShipOption, " strOrderSQL = strOrderSQL & "txtGiftMessage " strOrderSQL = strOrderSQL & " FROM " & STR_TABLE_ORDER strOrderSQL = strOrderSQL & " WHERE intID = " & intOrderID gobjConn.execute(strOrderSQL) set rsOrderData = gobjConn.execute("SELECT TOP 1 @@IDENTITY AS id FROM " & STR_TABLE_ORDER) if not rsOrderData.eof then CloneOrder = CInt(rsOrderData("id")) else CloneOrder = 0 end if end function sub MoveLineItem(intLineItemID, intNewOrderID) dim strSQL strSQL = "UPDATE " & STR_TABLE_LINEITEM & " SET intOrderID = " & intNewOrderID & " WHERE intID = " & intLineItemID gobjConn.execute(strSQL) end sub %>