<% 'Richiamo l' id del prodotto da inserire id_prodotto = request("id") 'Aggiunta nuovo prodotto nel Carrello 'Controllo che il prodotto sia già presente nel carrello if len(id_prodotto) <> 0 then strSQL = "select id_prodotto, id_user from tbl_Carrello where id_prodotto = " & id_prodotto & " and stato=0 and id_user = " & session("id_utente") set rs = DBConn.execute(strSQL) 'Se il prodotto non esiste, lo aggiungo 'Altrimenti aggiorno la quantita' di 1 unità if rs.eof then 'Aggiungo il prodotto strSQL = "insert into tbl_Carrello(id_user, id_prodotto, quantita) values(" & session("id_utente") & ", " & id_prodotto & ", 1)" DBConn.execute(strSQL) else 'Aggiorno la quantità strSQL = "update tbl_Carrello set quantita = quantita + 1 where id_prodotto = " & id_prodotto & " and id_user = " & session("id_utente") DBConn.execute(strSQL) end if rs.close set rs = nothing end if 'Fine 'Aggiorno il carrello if request("azione") = "aggiorna" then 'Controllo quali prodotti aggiornare o eliminare set rs = Server.CreateObject("ADODB.Recordset") rs.activeconnection = DBConn rs.cursortype = adOpenDynamic rs.locktype = adLockOptimistic strsql = "select * from tbl_Carrello where stato=0 and id_user = " & session("id_utente") rs.open strsql 'Elenco dei prodotti nel carrello 'E modifica... while not rs.eof pc = request("pc_" & rs("id_prodotto")) if isnumeric(pc) then if pc = 0 then rs.delete else rs("quantita") = pc end if end if rs.movenext wend 'Fine rs.close set rs = nothing 'Fine end if %> <% DEL=Request("DEL") If Not Nullo(DEL) Then ID=Request("ID") SQL="UPDATE tbl_carrello SET Quantita=0 WHERE stato=0 and id_prodotto=" & ID DBConn.Execute(SQL) Redirect "acquista_carrello_personale.php" End If %> <% Svuota=Request("Svuota") If Not Nullo(Svuota) Then ID=Request("ID") SQL="UPDATE tbl_carrello SET Quantita=0 WHERE stato=0 and id_user = " & session("id_utente") DBConn.Execute(SQL) Redirect "acquista_carrello_personale.php" End If %> <% EshopSex=Request("EshopSex") If Not Nullo(EshopSex) Then EshopSexNum=GeneraNumeroCasuale(1000000,9999999) SQL="UPDATE tbl_carrello SET id_ordine="& EshopSexNum &" WHERE stato=0 and id_user = " & session("id_utente") DBConn.Execute(SQL) Redirect "acquista_carrello_inoltra_ordine.php" End If %> Antica Norcineria "Fratelli Ansuini"
English Version
Azienda Prodotti Acquista Dove Siamo Norcia

<% 'Inizializzo le variabili per il prezzo totale var_tot = 0 'Visualizzo tutti i prodotti del carrello strSQL = "select id_prodotto, id_user, quantita from tbl_Carrello where quantita>0 and stato=0 and id_user = " & session("id_utente") set rs = DBconn.execute(strSQL) 'Il carrello e' vuoto ? if rs.eof then ScriviResponso ="Al momento, il Suo carrello e' vuoto." StatoCarrello=0 %> <% end if 'Fine 'Elenco dei prodotti while not rs.eof StatoCarrello=1 'Prelevo tutti i dati dal carrello id_prodotto = rs("id_prodotto") qnt = rs("quantita") 'Richiamo le informazioni relative al prodotto 'e aggiorno il valore del prezzo totale strSQL = "select nome, prezzo, TipPrezzo from tbl_Prodotti where id = " & id_prodotto set rs2 = DBconn.execute(strSQL) nome = rs2("nome") prezzo = rs2("prezzo") TipPrezzo = rs2("TipPrezzo") var_tot = var_tot + (prezzo * qnt) rs2.close set rs2 = nothing 'Fine 'Visualizzo i prodotti nella tabella %> <% rs.movenext wend %>
Prodotto
Quantità
Prezzo Unitario
Azioni
<%=ScriviResponso%>
<%=nome%> <%=TipPrezzo%>
<%=Euro(formatnumber(prezzo, 2))%> € al <%=TipPrezzo%>
<%if StatoCarrello=0 then%> <%else%> <%end if%>
Tot. <%=Euro(formatnumber(var_tot+(var_tot/100*20)))%> € (iva inclusa)
I prezzi dei singoli prodotti si intendono IVA esclusa.
<% rs.close set rs = nothing 'Fine %>
Carrello personale