Un carrito que usaba antes. Si quieres un carrito que vale para todo o uno simples enviarme un email o conteste la mensaje.
Código HTML:
<!--#include file="conexaoSQL.asp"-->
<%
If Session("cod_pedido") = "" Then
dim n_cod_pedido,subtotal
SQL1 = "SELECT MAX(id_ped) AS max_cod_pedido FROM Pedido"
Set RS_Max = Conn.Execute(SQL1)
If IsNull(RS_Max("max_cod_pedido")) Then
n_cod_pedido = 1
Else
n_cod_pedido = RS_Max("max_cod_pedido") + 1
End If
RS_Max.Close
Conn.Execute "INSERT INTO Pedido (id_ped,unidades,cod_prod,cor,tamanho) VALUES ('" & n_cod_pedido & "','" & Request.QueryString("quant") & "','" & Request.QueryString("id_prod") &"','" & Request.QueryString("cor") & "','" & Request.QueryString("tamanho") & "')"
Session("cod_pedido") = n_cod_pedido
End If
If Request.QueryString("id_prod") <> "" Then
SQL2="SELECT * FROM Pedido WHERE id_ped = '" & Session("cod_pedido") & " ' AND cod_prod = ' " & Request.QueryString("id_prod")& " ' AND cor = ' " & Request.QueryString("cor")& " ' AND tamanho = ' " & Request.QueryString("tamanho")& " '"
Set Rs = Conn.Execute(SQL2)
If RS.EOF Then
Conn.Execute "INSERT INTO Pedido (id_ped, cod_prod, unidades, cor , tamanho) VALUES ('" & Session("cod_pedido") & "', ' " & Request.QueryString("id_prod") & "' , ' " & Request.QueryString("quant") & " ',' " & Request.QueryString("cor") & " ', ' " & Request.QueryString("tamanho") & " ')"
end if
RS.Close
End If
%>
<%SQL3= "SELECT Pedido.*, Produto.nome, Produto.precio,Produto.promo,Produto.iva, Produto.peso,Produto.url_foto_p FROM Pedido, Produto WHERE id_ped = " & Session("cod_pedido") & " AND Pedido.cod_prod = Produto.cod_prod "
Set Rs_c = Conn.Execute(SQL3)%>
<%If RS_c.EOF = true then Response.write "<div align=center>No hay producto en la cesta.</div>" End if%>
<%
If Request.Form <> "" Then
' Chamada foi feita atraves do botao atualizar desta pagina
' Regrava todos os itens do pedido de acordo com os campos do formulario;
' Primeiro apaga tudo para regravar
Conn.Execute "DELETE FROM Pedido WHERE id_ped = " & Session("cod_pedido")
' Para cada campo do formulario, nome do campo é o código do produto a incluir
' e o valor do campo é a quantidade escolhida
For Each nome_controle In Request.Form
If Left(nome_controle,5) = "Quant" And Request.Form(nome_controle) <> "0" Then
nome_controle_cod_prod=Mid(nome_controle,7,5) 'Pega os caracteres a partir do sexto. O Máximo de codigos é 99.999.
comandoSQL = "INSERT INTO Pedido (id_ped, cod_prod, unidades, cor , tamanho) VALUES ("
comandoSQL = comandoSQL & Session("cod_pedido") & ", " & nome_controle_cod_prod & ", " & Request.Form(nome_controle) & ",' " & Request.QueryString("cor") & " ', ' " & Request.QueryString("tamanho") & " ')"
Conn.Execute comandoSQL
End If
Next
End If
%>
<link href="estilo1.asp" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo3 {color: #000000}
-->
</style><form name="form1" method="post" action="">
<table width="600" align="center">
<tr>
<th bgcolor="#FFCC33" scope="col"><table width="600" align="center" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr bgcolor="#FF9933" class="fora">
<td width="105" height="15" scope="col"><div align="left"></div></td>
<td width="56" scope="col">
<div align="center"><strong>Unidades</strong> </div></td>
<td width="185" scope="col"><div align="center">
<p align="left"><strong>Producto</strong><strong>s </strong></p>
</div></td>
<td width="52" scope="col"><div align="center"><strong>Precio</strong></div></td>
<td width="44" scope="col"><div align="center"><strong>Desc.</strong></div></td>
<td width="42" scope="col"><div align="center"><strong>Iva</strong> </div></td>
<td width="57" scope="col"><strong>Total </strong></td>
<td width="23" class="row2" scope="col"><div align="left" class="row2"> </div></td>
</tr>
<tr>
<%if RS_c.eof then
Response.Redirect "carrinhovazio.asp"
end if %>
<%RS_c.MoveFirst
do while not rs_c.eof
precio=rs_c("precio")
iva=rs_c("iva")
iva=iva/100
promo=rs_c("promo")
unidade=rs_c("unidades")
%>
<%
if promo <> 0 then
desc=FormatNumber((precio-promo)*unidade )
iva=promo * iva
p_total=(promo*unidade) + iva
else
desc = "-"
iva=(precio * iva) * unidade
p_total=(precio*unidade) + iva
end if
%>
<td height="67" scope="col">
<div align="left"><img src="imagens/<%=RS_c("url_foto_p")%>" width="100" height="65"> </div></td>
<td class="sobre" scope="col">
<div align="center">
<input name="Quant_<%= RS_c("cod_prod") %>" type="text" class="sobre" id="Quant_<%= RS_c("cod_prod") %>" value="<%=RS_c("unidades")%>" size="3">
</div></td>
<td class="row2" scope="col"> <div align="left"><%=RS_c("nome")%> <%cor1=RS_c("cor")
if cor1 <> "" then
Response.write cor1
end if%> <%=RS_c("tamanho")%></div></td>
<td class="title" scope="col"><div align="left"></div>
<div align="center"><%=FormatNumber(RS_c("precio"),2)%> €</div></td>
<td class="row1" scope="col"><div align="left"></div>
<div align="center">
<div align="center"> <%=desc%>
<%if promo<>0 then response.write"€" end if%>
</div>
</div></td>
<td class="hlight" scope="col"><div align="center"><%=FormatNumber(iva,2)%> €</div></td>
<td class="mainfoot" scope="col"><div align="center"><%=FormatNumber(p_total,2)%> €</div></td>
<td bgcolor="#FFFFFF" class="row2" scope="col"><div align="center"><a href="carrinho_delete.asp?id=<%=RS_c("cod_prod")%>"><img src="imagens/sistema/delete.gif" width="9" height="11" border="0"></a> </div>
<div align="center"></div></td>
</tr>
<tr> <% if rs_c("promo")<>0 then
subtotal = subtotal + rs_c("unidades")*rs_c("promo")+(rs_c("promo")*(rs_c("iva")/100))*rs_c("unidades")
ivaa=ivaa +(rs_c("promo")*(rs_c("iva")/100))*rs_c("unidades")
desconto=desconto+desc
else
desconto=desconto+0
ivaa=ivaa +(rs_c("precio")*(rs_c("iva")/100))*rs_c("unidades")
subtotal = subtotal + rs_c("unidades")*rs_c("precio")+(rs_c("precio")*(rs_c("iva")/100))*rs_c("unidades") end if %>
<%rs_c.movenext
loop%>
<td height="20" colspan="7" valign="top" class="fora" scope="col"><div align="right">DESCUENTO: <%=desconto%> €</div></td>
<td> </td>
</tr>
<tr>
<td height="20" colspan="7" valign="top" class="post2" scope="col"><div align="right">IVA: <%=FormatNumber(ivaa,2)%> €</div></td>
<td> </td>
</tr>
<tr>
<td height="20" colspan="7" valign="top" class="textinput" scope="col"><div align="right">TOTAL: <%=FormatNumber(subtotal,2)%>€ </div></td>
<td> </td>
</tr>
</table></th>
</tr>
</table>
<%Rs_c.Close
Set RS = Nothing
Conn.Close
Set RS_c = Nothing
Set Conn = Nothing
%>
<p align="center">
<input name="imageField" type="image" src="imagens/sistema/actualizar.gif" width="83" height="18" border="0">
<a href="pedido1.asp"> <img src="imagens/sistema/PEDIDO.gif" width="83" height="18" border="0"></a> </p>
</form>