<% ' Fehlerbehandlung SUB errorForm( theError ) %> Fehler
<%=theError %>
<%'Für das Zurückgeben der Formularfelder for each item in Request.form %> <% next %>

<% Response.End END SUB %> <% Set Con=Server.CreateObject("ADODB.Connection") Con.Open "weberorchideenDSN" Set euroRS=Server.CreateObject("ADODB.Recordset") euroRS.CursorType= adOpenStatic euroRS.ActiveConnection=Con euroRS.Open "SELECT * FROM eurokurs" eurokurs = euroRS("eurokurs") euroRS.Close %> <% ' Define Constants CONST CARTPID = 0 CONST CARTPNAME = 1 CONST CARTPPRICE = 2 CONST CARTPQUANTITY = 3 CONST CARTPCOLOR = 4 CONST CARTPTEXT = 5 ' Get The Shopping Cart IF NOT isArray( Session( "cart" ) ) THEN DIM localCart( 6, 20 ) ELSE localCart = Session( "cart" ) END IF ' Get Product Information productID = TRIM( Request( "pid" ) ) productName = TRIM( Request( "name" ) ) productPrice = TRIM( Request( "preis" ) ) productQuantity = TRIM (Request ("anzahl") ) productColor = TRIM (Request ("farbe") ) productText = TRIM (Request ("text") ) 'Fehlerbehandlung IF productID<>"" THEN IF NOT IsNumeric(productPrice) THEN errorform "Bitte eine Zahl für den Preis eingeben!" END IF IF NOT IsNumeric(productQuantity) THEN errorform "Bitte eine Zahl für die Anzahl eingeben!" END IF Set RS=Server.CreateObject("ADODB.Recordset") RS.CursorType= adOpenStatic RS.ActiveConnection=Con RS.Open "SELECT * FROM artikel WHERE artikelnummer=" & productID IF RS("von")<>"" THEN IF INT(productPrice) < INT(RS("von")) OR INT(productPrice) > INT(RS("bis")) THEN errorform "Der Artikel ist zu diesem Preis nicht lieferbar!" END IF END IF END IF ' Add Item to cart IF productID <> "" THEN foundIT = FALSE ' FOR i = 0 TO UBOUND( localCart ) ' IF localCart( CARTPID, i ) = productID THEN ' localCart( CARTPQUANTITY, i ) = localCart( CARTPQUANTITY, i ) + 1 ' foundIT = TRUE ' EXIT FOR ' END IF ' NEXT IF NOT foundIT THEN FOR i = 0 TO UBOUND( localCart, 2 ) IF localCart( CARTPID, i ) = "" THEN localCart( CARTPID, i ) = productID localCart( CARTPNAME, i ) = productName localCart( CARTPPRICE, i ) = productPrice localCart( CARTPQUANTITY, i ) = productQuantity localCart( CARTPCOLOR, i ) = productColor localCart( CARTPTEXT, i ) = productText EXIT FOR END IF NEXT END IF END IF ' Update Shopping Cart Quantities IF Request( "updateQ" ) <> "" THEN FOR i = 0 TO UBOUND( localCart, 2 ) deleteProduct = TRIM (Request ("pd" & localCart(CARTPID, i) ) ) IF deleteProduct <> "" THEN localCart( CARTPID, i ) = "" END IF NEXT END IF ' Update Session variable with Array Session( "cart" ) = localCart %> Warenkorb
Ihr Warenkorb:


<% END IF NEXT %>
Anz. Artikel Text od. Bemerkung Preis
<% orderTotal = 0 FOR i = 0 TO UBOUND( localCart, 2 ) IF localCart( CARTPID, i ) <> "" THEN orderTotal = orderTotal + ( localCart( CARTPPRICE, i ) * localCart( CARTPQUANTITY, i ) ) %>
<%=Server.HTMLEncode( localCart( CARTPQUANTITY, i ) )%> <%=Server.HTMLEncode( localCart( CARTPNAME, i ) )%> <%IF (localCart(CARTPCOLOR, i))<>"" THEN %>Farbe: <%=Server.HTMLEncode( localCart (CARTPCOLOR, i) )%>   <%END IF%> <%=Server.HTMLEncode( localCart (CARTPTEXT, i) )%>  <%=formatCurrency (( localCart( CARTPPRICE, i ) ) * (localCart(CARTPQUANTITY, i)) )%> (EUR <%=formatNumber(eurokurs*(localCart( CARTPPRICE, i )) * (localCart(CARTPQUANTITY, i)),2 )%>) Löschen

Total (exkl. Transportkosten): <%=formatCurrency( orderTotal )%> (EUR <%=formatNumber(eurokurs*ordertotal,2)%>)