<% ' Copyright (C) 1998-2005 CyberStrong Internet Services, Inc. All Rights Reserved ' ' This file has been seeded with unique information at point of sale and ' is traceable to its purchaser. ' ' Your license agreement forbids the removal of this notice. %> <% ' ' Review.asp - Display cart for customer review. ' ' Update the quantity and checked fields of the session shopping cart... Dim i, iCount, SQL, rstItem, iSubTotal, s Dim SplitArgs ' Holds the result of a split() call Dim Description ' The short or expanded product description Dim Status ' Status of user exit Dim ReturnValue ' Return value from user exit 'Dim FormErrorMsg ' Holds errors for later form display Dim MinQtyErrorMsg ' Holds errors for minimum quantity violations Dim iPass ' 1 for first load, 2 for refresh Dim ButtonPress ' The button pressed causing this load ' Lock cart out for maintenance ... If (isLocked() Or (Not isDataBaseCurrent())) Then Call DisplayMaintPage() Response.End End If ' GetFieldData() - Get field value from form ... Public Function GetFieldData(ByVal FieldName, ByVal DemoValue) Select Case True Case (gblDemoMode AND iPass = 1) : GetFieldData = DemoValue Case Else : GetFieldData = Request.Form(FieldName) End Select End Function ' UpdateCart() - Adjust quantities, remove deleted items. Public Sub UpdateCart () Dim i, x, n, Quantity, UnitPrice ' This and next loop may not be combined, quantity changes ' will be lost. If (iPass = 2) Then ' Adjust quantities, write-in prices, mark deleted items, total cart ... For i = 1 to iCount Quantity = Request("Quantity" & CStr(i)) If IsNumeric(Quantity) Then aryCart(cartItemQuantity, i) = abs(CSng(Quantity)) Else aryCart(cartItemQuantity, i) = CSng(1) End If If (cstAmountEditEnabled) Then UnitPrice = Replace(Request("UnitPrice" & CStr(i)), "$", "") If IsNumeric(UnitPrice) Then aryCart(cartUnitPrice, i) = abs(CDbl(UnitPrice)) End If End If aryCart(cartTotalPrice, i) = aryCart(cartUnitPrice, i) * _ aryCart(cartItemQuantity, i) ' Flag user checked and discount line items for deletion ... If (Request.Form("Keep" & CStr(i)) <> "y") Then aryCart(cartDeleted, i) = "y" End If Next End If ' (iPass = 2) ' Remove deleted items, slide following items down in array ... For i = 1 to iCount If ((aryCart(cartDeleted, i) = "y") OR _ (CStr(aryCart(cartItemQuantity, i)) = "0") OR _ (CStr(aryCart(cartItemType, i)) = "dsc") OR _ (CStr(aryCart(cartItemType, i)) = "cpn")) Then iCount = iCount - 1 For x = 1 to UBound(aryCart, 1) aryCart(x, i) = "" Next n = i While n < UBound(aryCart, 2) For x = 1 to UBound(aryCart, 1) aryCart(x, n) = aryCart(x, n + 1) aryCart(x, n + 1) = "" Next n = n + 1 Wend i = i - 1 End If Next ' Add earned discounts to cart ... If (IsInstalled("Feature:Discounts") AND cstDiscountsEnabled) Then FeatureInstalled("Feature:Discounts").AddToCart() End If ' Add coupons tendered to cart ... If (IsInstalled("Feature:Coupons") AND cstCouponsEnabled) Then FeatureInstalled("Feature:Coupons").AddToCart() End If ' User exit for pricing and quantity adjustment ... Status = UserExit(usrAdjustCart, Conn, 0, 0, 0, ReturnValue) ' Save values to Session ... Session(sesShoppingCart) = aryCart Session(sesItemCount) = iCount End Sub ' CheckMinQtys() - Check cart for mininum item requirements, ' Summarize order by product accross options ' to meet qty requirement ... Public Sub CheckMinQtys() Dim lstItems, aryProductList, aryQtyInfo(2), aryTemp, Key, aryKeys ' Omit check for min qty if this feature is disabled ... If (Not cstMinOrderQtyEnabled) Then Exit Sub End If ' Indexes for aryQtyInfo() Const idxMinQty = 0 Const idxTotalQty = 1 Const idxOptions = 2 ' Build a summary of all products in the cart by qty ... set lstItems = Server.CreateObject("Scripting.Dictionary") MinQtyErrorMsg = "" For i = 1 to iCount ' If this product exists in the dictionary, add ' customers order qty to it, otherwise, create this ' product in the dictionary. Key = aryCart(cartProductCode, i) If (lstItems.Exists(Key)) Then aryTemp = lstItems.Item(Key) aryTemp(idxTotalQty) = aryTemp(idxTotalQty) + CSng(aryCart(cartItemQuantity, i)) lstItems.Item(Key) = aryTemp Else aryQtyInfo(idxMinQty) = CSng(aryCart(cartMinQuantity, i)) aryQtyInfo(idxTotalQty) = CSng(aryCart(cartItemQuantity, i)) aryQtyInfo(idxOptions) = aryCart(cartOptions, i) lstItems.Add Key, aryQtyInfo End If Next ' Cycle through summary, check min qtys ... aryKeys = lstItems.Keys For i = 0 To (lstItems.Count - 1) If (lstItems.Item(aryKeys(i))(idxTotalQty) < lstItems.Item(aryKeys(i))(idxMinQty)) Then MinQtyErrorMsg = MinQtyErrorMsg & _ " " & _ "The minimum order quantity for product " & aryKeys(i) & " is " & _ lstItems.Item(aryKeys(i))(idxMinQty) & ".
" End If Next ' Force purchase of minimum qtys on items that have no options ... For i = 1 to iCount If (aryCart(cartOptions, i) = "") Then If (CSng(aryCart(cartItemQuantity, i)) < CSng(aryCart(cartMinQuantity, i))) Then aryCart(cartItemQuantity, i) = aryCart(cartMinQuantity, i) End If End If Next ' Clear the dictionary ... lstItems.RemoveAll ' Release objects ... set lstItems = Nothing End Sub ' CalculateSubTotal() - Calculate subtotal to iSubTotal ... Public Sub CalculateSubTotal() iSubTotal = 0 For i = 1 to iCount If ((aryCart(cartUnitPrice,i)) <> "") Then iSubTotal = iSubtotal + aryCart(cartTotalPrice, i) End If Next iSubTotal = IIF(iSubTotal < 0, 0, iSubTotal) End Sub ' DisplayButtons() - Display action buttons ... Public Sub DisplayButtons() Dim rs If (iCount < MaxShoppingCartItems) Then set rs = Server.CreateObject("ADODB.Recordset") rs.Open "Products", Conn, adOpenKeyset, adLockOptimistic If (rs.RecordCount <> 1) Then wl("  ") End If rs.Close set rs = Nothing End If If (iCount > 0) Then wl("  ") End If wl("  ") If (iCount > 0) Then wl("  ") End If End Sub ' ProductHasOptions() - Returns True if the given product code has options, ' Considers shared options as well. Public Function ProductHasOptions(ByVal argProductCode) Dim rs, SQL ProductHasOptions = False ' Direct options ... If (isOptionsAvail(GetURLValue("ProductCode"))) Then ProductHasOptions = True Exit Function End If If (cstSharedOptionsEnabled) Then ' Shared options ... Set rs = Server.CreateObject("ADODB.Recordset") SQL = "SELECT OptionsUseProductCode FROM Products " & _ "WHERE ({fn UCASE(ProductCode)} = '" & CleanSQL(Ucase(argProductCode), "a") & "')" rs.Open SQL, Conn, adOpenKeyset, adLockOptimistic If (rs.RecordCount <> 0) Then If (isOptionsAvail(rs("OptionsUseProductCode"))) Then ProductHasOptions = True End If End If rs.Close : Set rs = Nothing End If End Function ' isOptionsAvail() - Returns True if options are available and active for the given product code. Public Function isOptionsAvail(ByVal argProductCode) Dim rs, SQL SQL = "SELECT DISTINCT Options.TypeID, OptionTypes.Active FROM Options " & _ "INNER JOIN OptionTypes ON Options.TypeID = OptionTypes.ID " & _ "WHERE ({fn LCASE(OptionTypes.Active)} <> 'no') AND " & _ " ({fn UCASE(Options.ProductCode)} = '" & CleanSQL(Ucase(argProductCode), "a") & "') " & _ "ORDER BY TypeID" set rs = Server.CreateObject("ADODB.Recordset") rs.Open SQL, Conn, adOpenKeyset, adLockOptimistic isOptionsAvail = CBool(rs.RecordCount <> 0) rs.Close : Set rs = Nothing End Function ' Main: --------------------------------------------------------------------------------- FormErrorMsg = "" iPass = 1 ' Need this here, in the event that the 10Browse.asp module is not being used ... If (Session(sesInit) = "") Then Session("OrderID") = 0 ' For passing to thank you screen Session(sesInit) = "True" ' Confirms that we are started End If ' Create shopping cart if necessary ... Call crtCreate() ' Confirm no session timeout ... Call ConfirmSessionOk(sesItemCount) ' Recover session variables ... If (Session(sesItemCount) <> "") Then iCount = Session(sesItemCount) aryCart = Session(sesShoppingCart) End If ' Record customer's IP address and language now, ' as this info may be lost when the cart goes secure ... Session("REMOTE_ADDR") = Request.ServerVariables("REMOTE_ADDR") Session("HTTP_ACCEPT_LANGUAGE") = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") ' Open the database ... Set Conn = dbOpen("rwl") iPass = IIF(Request.Form("isFormPost") = "True", 2, 1) Call UpdateCart() Call CheckMinQtys() ' Process form events ------------------------------------------------- ButtonPress = LCase(GetFormAction()) SELECT CASE True CASE ButtonPress = "continue" If (FormErrorMsg = "") Then Session(sesShoppingCart) = aryCart Session(sesItemCount) = iCount s = OurSession("ReturnTo") OurSession("ReturnTo") = "" If ((s <> "") AND (LCase(Left(s, 10)) <> "msetup.asp")) Then dbClose(Conn) Response.Redirect(s) Else OurSession("txtCategory") = Request.Form("txtCategory") OurSession("txtSearchString") = Trim(Request.Form("txtSearchString")) dbClose(Conn) Response.Redirect(cstBrowseStartPageURL) End If End If Call UpdateCart() Call CheckMinQtys() CASE ButtonPress = "recalculate" Session(sesShoppingCart) = aryCart Session(sesItemCount) = iCount CASE ButtonPress = "cancelorder" dbClose(Conn) Session.Abandon Response.Redirect(cstCancelURL) CASE ButtonPress = "agree" dbClose(Conn) Response.Redirect("30GetCst.asp") CASE ButtonPress = "checkout" Call CalculateSubTotal() If (CDbl(iSubTotal) < CDbl(cstMinOrderAmount)) Then FormErrorMsg = FormErrorMsg & _ " " & _ "The minimum order for checkout is " & _ OurFormatCurrency(cstMinOrderAmount) & ".
" End If If ((FormErrorMsg & MinQtyErrorMsg) = "") Then Session(sesItemCount) = iCount Session(sesShoppingCart) = aryCart dbClose(Conn) If (iCount > 0) Then ' Display terms and conditions file if exists, or move to 30GetCst.asp ... If (FileExists("Terms.htm")) Then Call DisplayPageHeader("20", "", "") wl("") wl("") wl("
" & ReadFile("Terms.htm") & "
") wl("
") wl("  ") wl("") wl("
") wl("
") Response.End Else Response.Redirect("30GetCst.asp") End If Else Response.Redirect(cstBrowseStartPageURL) End If End If Case ButtonPress = "viewall" OurSession("SelectedCategory") = "" OurSession("BrowseSQL") = "" OurSession("SearchString") = "" OurSession("txtSearchStringLast") = "" OurSession("txtCategoryLast") = "" Session(sesItemCount) = iCount Session(sesShoppingCart) = aryCart dbClose(Conn) Response.Redirect("10Browse.asp") Case (Request.Form("txtCategory") <> OurSession("txtCategoryLast")) AND _ (Request.Form("txtCategory") <> "") OurSession("txtCategory") = Request.Form("txtCategory") Session(sesItemCount) = iCount Session(sesShoppingCart) = aryCart dbClose(Conn) Response.Redirect("10Browse.asp") Case (ButtonPress = "search") OR _ ((Trim(Request.Form("txtSearchString")) <> OurSession("txtSearchStringLast")) AND _ (Trim(Request.Form("txtSearchString")) <> "")) OurSession("txtSearchString") = Trim(Request.Form("txtSearchString")) Session(sesItemCount) = iCount Session(sesShoppingCart) = aryCart dbClose(Conn) Response.Redirect("10Browse.asp") CASE ButtonPress = "go" ' Note: This is the default button for this form and must ' be tested last ... Session(sesShoppingCart) = aryCart Session(sesItemCount) = iCount OurSession("txtCategory") = Request.Form("txtCategory") OurSession("txtSearchString") = Trim(Request.Form("txtSearchString")) dbClose(Conn) Response.Redirect("10Browse.asp") Case Else ' Initial page load ... If (GetURLValue("ReturnTo") <> "") Then OurSession("ReturnTo") = GetURLValue("ReturnTo") End If ' If a product code was passed, add this product to ' the current shopping cart If (GetURLValue("ProductCode") <> "") Then ' Check to see if this product has options, if so, send user to ' options page to select them. Item will be added to cart on ' options page so we will won't need to come here again. If (ProductHasOptions(GetURLValue("ProductCode"))) Then dbClose(Conn) Response.Redirect("10Expand.asp?ProductCode=" & GetURLValue("ProductCode")) End If ' Otherwise, look up data on this product and add it to the cart. ' vis=1 means that product must not be hidden or out of date range. If (GetURLValue("vis") = 1) Then SQL = "" SQL = SQL & "SELECT * FROM Products " SQL = SQL & "WHERE " If (cstDisplayDatesEnabled) Then SQL = SQL & "((ProductStartDate Is Null) OR (ProductStartDate <= {fn Now()})) AND " SQL = SQL & "((ProductEndDate Is Null) OR (ProductEndDate >= {fn Now()})) AND " End If If (cstProductHideEnabled) Then SQL = SQL & "{fn LCase(ProductHide)} <> 'yes' AND " End If SQL = SQL & "{fn UCASE(ProductCode)} = '" & Ucase(GetURLValue("ProductCode")) & "' AND " SQL = SQL & "(1 = 1) " If (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductSortCode" End If Else SQL = "SELECT * FROM Products WHERE {fn UCASE(ProductCode)} = '" & CleanSQL(Ucase(GetURLValue("ProductCode")), "a") & "'" End If set rstItem = Server.CreateObject("ADODB.Recordset") rstItem.Open SQL, Conn, adOpenKeyset, adLockOptimistic If (rstItem.RecordCount <> 0) Then aryCartData(cartProductID) = rstItem("ProductID") aryCartData(cartProductCode) = rstItem("ProductCode") aryCartData(cartProductName) = rstItem("ProductName") aryCartData(cartProductDescription) = rstItem("ProductDescription") aryCartData(cartProductDescriptionLong) = rstItem("ProductDescriptionLong") aryCartData(cartCategory) = rstItem("ProductCategory") aryCartData(cartCoupons) = rstItem("ProductCoupons") aryCartData(cartProductShipsFree) = rstItem("ProductShipsFree") aryCartData(cartShippingUnits) = rstItem("ShippingUnits") aryCartData(cartUnitPrice) = rstItem("UnitPrice") aryCartData(cartOptions) = "" aryCartData(cartDiscountName ) = rstItem("DiscountName") aryCartData(cartDownloadFileName) = rstItem("DownloadFileName") aryCartData(cartAllowAmountEdit) = rstItem("AllowAmountEdit") aryCartData(cartTaxOverride) = rstItem("TaxOverride") aryCartData(cartNotes) = rstItem("Notes") aryCartData(cartNSN) = rstItem("NSN") aryCartData(cartPackaging) = rstItem("Packaging") aryCartData(cartSKU) = rstItem("SKU") '************coded inserted august 29,2005**********start ' aryCartData(larryNotes) = rstItem("StampParams") '************coded inserted august 29,2005**********end If (cstSalePriceEnabled AND (Not IsNullOrZero(rstItem("SalePrice")))) Then aryCartData(cartUnitPrice) = rstItem("SalePrice") Else if session("Organization") = "Federal" then aryCartData(cartUnitPrice) = rstItem("FedSalePrice") elseif session("Organization") = "State" then aryCartData(cartUnitPrice) = rstItem("StateSalePrice") elseif session("Organization") = "Reseller" then aryCartData(cartUnitPrice) = rstItem("ResellerSalePrice") elseif session("Organization") = "Local Government" then aryCartData(cartUnitPrice) = rstItem("LocalGovSalePrice") elseif session("Organization") = "Corporation" then aryCartData(cartUnitPrice) = rstItem("CorporationSalePrice") else aryCartData(cartUnitPrice) = rstItem("UnitPrice") End if End If If (cstMinOrderQtyEnabled AND (Not IsNull(rstItem("MinQty")))) Then aryCartData(cartItemQuantity) = rstItem("MinQty") aryCartData(cartMinQuantity) = rstItem("MinQty") Else aryCartData(cartItemQuantity) = 1 aryCartData(cartMinQuantity) = 1 End If aryCartData(cartItemType) = "usr" ' Add this item to the shopping cart ... crtAddToCart(aryCartData) rstItem.Close : Set rstItem = Nothing Else FormErrorMsg = FormErrorMsg + "The item you have selected is presently unavailable.
" End If ' (rstItem.RecordCount <> 0) End If ' (GetURLValue("ProductCode") <> "") Call UpdateCart() Call CheckMinQtys() End Select ' Calculate the orders total so far ... Call CalculateSubTotal() ' Save cart ... Session(sesItemCount) = iCount Session(sesShoppingCart) = aryCart ' Write the page ... wl("
") wl("
") ' Page position table start ... Call DisplayPageHeader("20", "", "") wl("
 
") If ((cstDisplayCategoryDDB AND cstCategoriesEnabled) OR cstDisplaySearchBox) Then wl("") wl("") If (cstDisplaySearchBox) Then wl("") Else wl("") End If wl("
") Call catDisplayDDB() wl("") wl(" ") wl(" ") If (cstViewAllButtonEnabled) Then wl("") End If wl(" 
") End If wl("") wl("") wl("") wl("") wl("
") ' Display errors, if any ... If ((FormErrorMsg & MinQtyErrorMsg) <> "") Then wl("
" & FormErrorMsg & MinQtyErrorMsg) End If If (iCount = 0) Then wl("
There are no items in your shopping cart.
") Else wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("") ' Order detail ... For i = 1 to iCount wl("") ' Product code ------------------------------------ wl("") ' Product description ---------------------------- wl("") ' Quantity ---------------------------------------- wl("") ' Unit Price -------------------------------------- If (cstAmountEditEnabled AND (LCase(Trim(aryCart(cartAllowAmountEdit, i))) = "yes")) Then wl("") Else wl("") End If ' Total Price ------------------------------------- wl("") wl("") wl("") Next ' Shopping cart detail line ' BEGIN subtotal wl("") wl("") wl("") wl("") wl("") wl("
") wl("Code") wl("") wl(" Description") wl("") wl("Qty") wl("") wl(" Each") wl("") wl(" Total") wl("
") If (aryCart(cartItemType, i) = "usr") Then Response.Write(" ") End If If ((aryCart(cartItemType, i) = "usr") And cstLinkExpandOnCheckout) Then '************coded inserted august 26,2005**********start if aryCart(larryNotes, i)<>"" then%> <%=aryCart(cartProductCode, i)%><% else '************coded inserted august 26,2005**********end Response.Write("" & aryCart(cartProductCode, i) & "") '************coded inserted august 26,2005**********start end if '************coded inserted august 26,2005**********end Else Response.Write("" & aryCart(cartProductCode,i) & "") End If wl("") wl("") wl(aryCart(cartProductName,i) & "
") Response.Write(GetShortDescription(aryCart(cartProductDescription, i), "")) & "" '************coded inserted august 27,2005**********start if aryCart(larryNotes, i)<>"" then%> <%dim larTmp1 larTmp1="" if aryCart(cartOptions,i)<>"" then larTmp1="Nameplate" else larTmp1="Stamp" end if%>
Edit Your <%=larTmp1%> | View Your <%=larTmp1%><% end if '************coded inserted august 27,2005**********end ' Offer discount schedule for viewing if available ... If (IsInstalled("Feature:Discounts") AND cstDiscountsEnabled) Then FeatureInstalled("Feature:Discounts").WriteLink(i) End If Response.Write(FormatOptions(aryCart(cartOptions,i))) wl("
") If (aryCart(cartItemType, i) = "usr") Then wl("") Else wl("" & aryCart(cartItemQuantity, i) & "") End If wl("") wl("") wl("") wl("" & OurFormatCurrency(aryCart(cartUnitPrice,i)) & "") wl("") wl("" & OurFormatCurrency(aryCart(cartTotalPrice, i)) & "") wl("
Subtotal:" & OurFormatCurrency(iSubtotal) & "
") End If ' Else iCount = 0 ' Collect Coupon info from user if installed and enabled ... If (IsInstalled("Feature:Coupons") AND cstCouponsEnabled) Then FeatureInstalled("Feature:Coupons").GetCouponsFromUser() End If ' Display recommend products (cross selling) if installed and enabled ... If (IsInstalled("Feature:Cross Sell") AND cstCrossSellEnabled) Then FeatureInstalled("Feature:Cross Sell").Recommend() End If ' Display shipping preview if enabled ... If (cstShipPreviewEnabled) Then Call DisplayPreviewShippingPanel() End If wl("
") wl("
") wl("
") Call DisplayButtons() wl("
") wl("

") Call DisplayAffiliateLink() wl("
") wl("
") ' Page position table end. ' Used to detect if this load was from a POST or link ... wl("") wl("
") dbClose(Conn) '************coded inserted august 26,2005**********start %> <% Dim larrycart,arr,arr1,arr2,ilar,jlar,arr3 For ilar = 1 to iCount if aryCart(larryNotes, ilar)<>"" then%>
<% larrycart=aryCart(larryNotes, ilar) arr=Split(larrycart,"") arr1=Split(arr(0),";") Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" arr1=Split(arr(1),";") for jlar=Lbound(arr1) to Ubound(arr1) arr2=Split(arr1(jlar),":") Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" next Response.Write "" arr1=Split(arr(3),"") for jlar=Lbound(arr1) to Ubound(arr1) arr2=Split(arr1(jlar),"") Response.Write "" arr3=Split(arr2(1),":") Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" next arr3=Split(arr(4),"") if Ubound(arr3)>0 then dim tql tql=Split(arr3(1),"") Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" else Response.Write "" end if if UBound(arr)>5 then arr1=Split(arr(5),";") Response.Write "" Response.Write "" Response.Write "" 'Response.Write "" 'Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" arr1=Split(arr(6),";") for jlar=Lbound(arr1) to Ubound(arr1) arr2=Split(arr1(jlar),":") Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" next Response.Write "" arr1=Split(arr(8),"") for jlar=Lbound(arr1) to Ubound(arr1) arr2=Split(arr1(jlar),"") Response.Write "" arr3=Split(arr2(1),":") Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "" next 'Response.Write "" end if end if %> <% Next '************coded inserted august 26,2005**********end %>