Salve a tutti, premetto che non sono una cima in asp, me a cavicchio solo.
Ho cercato nel forum ma non ho trovato la risposta al mio problema, quindi ecco quà:
sto cercando di realizzare per un amico un piccolo shop on-line senza troppe pretese (niente pagamenti con carte di credito ma solo in contrassegno postale). Ho trovato un esempio molto semplice di carrello eletronico su www.asp101.com che fa esattamente quello che vogliamo. Quando si accede all'elenco dei prodotti nel carrello ho inserito un form per richiedere i dati del cliente per la fatturazione/spedizione della merce. Una volta immessi i dati, e dato conferma dell'ordine, mi viene spedita una mail con l'ordine e i dati del cliente.
Tutto funziona, solo che nel corpo della mail vene riportato l'elenco dei prodotti richiesti, ma non i dati del cliente.
Mi potete aiutare?
Ecco parte del listato con l'inserimento dati cliente (non metto tutto il listato perché è un poco lungo):
<table width="698" border="0" cellpadding="3" cellspacing="1" class="style1">
<tr>
<td width="66">Codice</td>
<td width="180">Nome prodotto</td>
<td width="58">Quantità</td>
<td width="186">Rimuovi l'articolo dal carrello </td>
<td width="80">Prezzo</td>
<td width="71">Totale</td>
</tr>
<%
sTotal = 0
For Each objKey in dictCart
aParameters = GetItemParameters(objKey)
%>
<tr>
<td align="center"><%= objKey %></td>
<td align="left"><%= aParameters(1) %></td>
<td align="center"><%= dictCart(objKey) %></td>
<td align="left">Uno
Tutti</td>
<td align="right">€<%= aParameters(2) %></td>
<td align="right">€<%= FormatNumber(dictCart(objKey) * CSng(aParameters(2)), 2) %></td>
</tr>
<%
sTotal = sTotal + (dictCart(objKey) * CSng(aParameters(2)))
Next
' Calculate shipping
sShipping = CalculateShippingCost(sTotal)
' Add shipping to total
sTotal = sTotal + sShipping
%>
<tr>
<td colspan="5" align="right">Spese di spedizione :</td>
<td align="right">€<%= FormatNumber(sShipping, 2) %></td></tr>
<tr>
<td colspan="5" align="right">Totale:</td>
<td align="right">€<%= FormatNumber(sTotal, 2) %></td></tr>
</table>
<p class="style2">Destinatario merce e fattura</p>
<form action="shopping.asp?id=" method="post" name="cliente" id="cliente">
<table width="513" border="0" class="style1">
<tr>
<td colspan="2" align="center"><div align="left">Si prega di compilare tutti i campi, altrimenti l'ordine non sarà ritenuto valido.</div></td>
</tr>
<tr>
<td width="122"></td>
<td width="381"></td>
</tr>
<tr>
<td align="right">Nome:</td>
<td><input name="nome" type="text" id="nome" size="40" maxlength="50"></td>
</tr>
<tr>
<td align="right">Cognome:</td>
<td><input name="cognome" type="text" id="cognome" size="40" maxlength="50"></td>
</tr>
<tr>
<td align="right">Codice fiscale/P.Iva:</td>
<td><input name="cf" type="text" id="cf" size="40" maxlength="50"></td>
</tr>
<tr>
<td align="right">Indirizzo:</td>
<td><input name="indirizzo" type="text" id="indirizzo" size="40" maxlength="80"></td>
</tr>
<tr>
<td align="right">Città:</td>
<td><input name="citta" type="text" id="citta" size="40" maxlength="50"></td>
</tr>
<tr>
<td align="right">Provincia:</td>
<td><input name="provincia" type="text" id="provincia" size="40" maxlength="50"></td>
</tr>
<tr>
<td align="right">Telefono:</td>
<td><input name="telefono" type="text" id="telefono" size="40" maxlength="50"></td>
</tr>
</table>
</form>
Mentre i pulsanti in fondo alla pagina sono questi:
[img]images/shop_look.gif[/img]
[img]images/shop_checkout.gif[/img]
Ora passiamo all'invio dell'email:
Dim objMessage, strMessageBody
strMessageBody = "Quantita' Codice Nome prodotto Prezzo Totale" & vbCrLf & vbCrLf
For Each objKey in dictCart
aParameters = GetItemParameters(objKey)
strMessageBody = strMessageBody & " " & dictCart(objKey)
strMessageBody = strMessageBody & " " & objKey
strMessageBody = strMessageBody & " " & aParameters(1)
strMessageBody = strMessageBody & String(25 - Len(aParameters(1)), " ") & aParameters(2)
strMessageBody = strMessageBody & " " & FormatNumber(dictCart(objKey) * CSng(aParameters(2)), 2) & vbCrLf
Next
strMessageBody = strMessageBody & vbCrLf
strMessageBody = strMessageBody & String(30, " ") & "Spese di spedizione: " & FormatNumber(sShipping, 2) & vbCrLf
strMessageBody = strMessageBody & vbCrLf
strMessageBody = strMessageBody & String(39, " ") & "Totale: " & FormatNumber(sTotal, 2) & vbCrLf
strMessageBody = strMessageBody & vbCrLf
strMessageBody = strMessageBody & "Dati fattutazione/spedizione" & vbCrLf
strMessageBody = strMessageBody & "Cognome: " & Request.Form("cognome") & vbCrLf
strMessageBody = strMessageBody & "Nome:" & Request.Form("nome") & vbCrLf
strMessageBody = strMessageBody & "C.F./P.IVA:" & Request.Form("cf")
'Response.Write "<pre>" & strMessageBody & "</pre>"
Set objMessage = Server.CreateObject("CDO.Message")
With objMessage
' Set message attributes
.To = "pippo<pippo@pippo.it>"
.From = "pippo<pippo@pippo.it>"
.Subject = "Nuovo ordine"
.TextBody = strMessageBody
' Send message - uncomment the following line only
' AFTER you've entered appropriate To and From
' addresses above. Then the script will actually
' send the messages.
.Send
End With
Set objMessage = Nothing