Comunidad de diseño web y desarrollo en internet online

Carrito de compra - Sacar variables de sesion

Citar            
MensajeEscrito el 18 Mar 2008 08:33 am
Buenas!

Estoy armando un carro de compras para una web de moda.

He pillando codigos de por ahí y los estoy depurando...pero tengo un problema....

tengo todo menos cuando pido los datos al cliente... listo los productos comprados y los envio via email...

a ver si alguien sabe....

Os paso el codigo

<%@LANGUAGE="VBSCRIPT"%>
<%
'Option Explicit%>
<%Response.Buffer=True%>
<HTML>
<HEAD>
<TITLE>Carrito de compras</TITLE>
<%
' SHOP.ASP

Sub MostrarCatalogo '****************************************************

Dim oRs, oRs2, SQL
Dim idmarca
Set oRs=Server.CreateObject("ADODB.Recordset")
Set oRs2=Server.CreateObject("ADODB.Recordset")
SQL="SELECT * FROM Productos;"
oRs.Open SQL, oConn
%>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-image: url(img/fondoproductos.png);
background-repeat: repeat-x;
background-color: #000000;
font-family: Verdana;
font-size: 12px;
font-weight: bold;
color: #CCCCCC;
}
-->
</style>
<link href="estiles.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo1 {
font-size: 10px;
color: #FFFFFF;
}
.Estilo2 {font-size: 12}
#Layer1 {
position:absolute;
left:15px;
top:312px;
width:28px;
height:26px;
z-index:1;
}
-->
</style>
<TABLE width="463" BORDER=0 CELLPADDING="1" CELLSPACING="1">
<TR>
<TD width="96" bgcolor="#7EBD4A"><div align="center"><B class="Productos">Marca</B></div></TD>
<TD width="114" bgcolor="#7EBD4A"><div align="center"><B class="Productos">Producto</B></div></TD>
<TD width="86" bgcolor="#7EBD4A"><div align="center"><B class="Productos">Precio</B></div></TD>
<TD width="72" bgcolor="#7EBD4A"></TD>
<TD width="79" bgcolor="#7EBD4A"><div align="center"><a href="shop.asp?ac=ver"><img src="img/carrito.png" width="35" height="29" border="0"><br>
<span class="Descripcion Estilo1">Ver carrito</span></a></div></TD>

<%
Do until oRs.EOF
idmarca=oRs.Fields("Marca")
SQL="SELECT * FROM Marcas WHERE IdMarca="&idmarca&";"
oRs2.Open SQL, oConn
%>
<TR>
<TD bgcolor="#333333"><div align="center"><A HREF="detalle.asp?idmarca=<%=oRs.Fields("IdProducto")%>" class="Descripcion"><%=oRs2.Fields("Nombre")%></A></div></TD>
<TD bgcolor="#333333" class="Descripcion"><div align="center"><%=oRs.Fields("Nombre")%></div></TD>
<TD bgcolor="#333333" class="Descripcion"><div align="center"><%=oRs.Fields("Precio")%></div></TD>
<TD bgcolor="#333333"><div align="center"><A HREF="shop.asp?ac=meter&prod=<%=oRs.Fields("IdProducto")%>" class="Productos">Comprar</A></div></TD>
<TD bgcolor="#333333"><div align="center"><img src="fotos/<%=oRs.Fields("img")%>" alt="" width="40" height="40" border="0" style="background-color: #CC0000"></div></TD>
</TR>
<%
oRs2.Close
oRs.MoveNext
Loop
%>
</TABLE>
<%
oRs.Close
Set oRs=Nothing
Set oRs2=Nothing
%>
<center>
</center>

<span class="Productos">
<%
End Sub'********************************************************************

Sub MostrarCarrito'*********************************************************

Dim oRs, oRs2, SQL
Dim clave
Dim gastos
Dim total, subtotal
gastos=12
total=0
subtotal=0
Set oRs=Server.CreateObject("ADODB.Recordset")
%>
<style type="text/css">
<!--
body {
background-image: url(img/fondoproductos.png);
background-repeat: repeat-x;
background-color: #000000;
}
-->
</style>
</span>
<link href="estiles.css" rel="stylesheet" type="text/css">

<span class="Productos">
<style type="text/css">
<!--
.Estilo1 {
font-size: 10px;
color: #FFFFFF;
}
-->
</style>
</span>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1">
<TR>
<TD bgcolor="#7EBD4A" class="Productos">Artículo</TD>
<TD bgcolor="#7EBD4A" class="Productos">Cantidad</TD>
<TD bgcolor="#7EBD4A" class="Productos">Precio/unidad</TD>
<TD bgcolor="#7EBD4A" class="Productos">Quitar del carrito</TD>
<TD bgcolor="#7EBD4A" class="Productos">Total</TD>
</TR>
<%
For Each clave In carrito
subtotal=0
SQL="SELECT * FROM Productos WHERE IdProducto="&clave&";"
Set oRs=oConn.Execute(SQL)
%>
<TR>
<TD bgcolor="#333333" class="Descripcion"><%=oRs.Fields("Nombre")%></TD>
<TD bgcolor="#333333" class="Descripcion"><%=carrito(clave)%></TD>
<TD bgcolor="#333333" class="Descripcion"><%=oRs.Fields("Precio")%></TD>
<TD bgcolor="#333333"><A HREF="shop.asp?ac=sacar&prod=<%=clave%>&cant=1" class="Descripcion">Quitar Uno</A>
<A HREF="shop.asp?ac=sacar&prod=<%=clave%>&cant=<%=carrito(clave)%>" class="Descripcion">Quitar Todos</A> </TD>
<%
subtotal=CSng(FormatNumber(carrito(clave))*oRs.Fields("Precio"))
total=total+subtotal
%>
<TD bgcolor="#333333" class="Descripcion"><%= subtotal %></TD>
</TR>
<%
Next
If carrito.Count > 0 Then
oRs.Close
Set oRs=Nothing
End If
%>
<TR>
<TD COLSPAN=4 bgcolor="#333333" class="Productos">Gastos de envío</TD>
<TD bgcolor="#333333" class="Descripcion">
<%
If total=0 Then
Response.Write("0")
Else
Response.Write(gastos)
End If
%> </TD>
<TR>
<TD COLSPAN=4 bgcolor="#7EBD4A"><B class="Productos">Total:</B></TD>
<TD bgcolor="#7EBD4A" class="Productos">
<%if total=0 Then
Response.Write("0")
Else
Response.Write(total+gastos)
End If
%> </TD>
<TR>
<TD COLSPAN=5 bgcolor="#7EBD4A"><div align="center"><span class="Productos"><A HREF=shop.asp>Seguir mirando</A> / <A HREF=shop.asp?ac=fin>Pasar por caja</A></span></div></TD>
</TABLE>
<span class="Productos">
<%
If accion<>"fin" Then
%>
</span>
<style type="text/css">
<!--
body {
background-image: url(img/fondoproductos.png);
background-repeat: repeat-x;
background-color: #000000;
font-family: Verdana;
font-size: 12px;
font-weight: bold;
color: #CCCCCC;
}
-->
</style>

<H2 class="Productos">
<%
End If
End Sub'********************************************************************


Sub MeterArticulo (id)'******************************************************

If carrito.Exists(id) Then
carrito(id)=carrito(id)+1
Else
carrito.Add id, 1
End If

Response.Write("Se ha a&ntilde;adido el art&iacute;culo al carrito<br>")

End Sub'********************************************************************


Sub SacarArticulo (id, cantidad)'*******************************************

If Not carrito.Exists(id) Then
Response.Write("&iexcl;No tienes eso en tu carrito!")
Else
If cantidad>1 Then
carrito.Remove(id)
Else
carrito(id)=carrito(id)-1
If carrito(id)<1 Then
carrito.Remove(id)
End If
End If
End If
End Sub'********************************************************************

Sub PasarPorCaja'***********************************************************

%>
</H2>
<H2 class="Precios">¡Gracias por su compra!</H2>
<span class="Productos">
<%
MostrarCarrito
%>

%>
<%
Set Session("carrito")=Nothing
End Sub'********************************************************************


Dim carrito
Dim accion
Dim producto
Dim cant
Dim oConn
%>
</span>
<P>
<%
Set oConn=Server.CreateObject("ADODB.Connection")
oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("data\tienda.mdb")
If IsObject(Session("carrito")) Then
Set carrito=Session("carrito")
Else
Set carrito=Server.CreateObject("Scripting.Dictionary")
End If
accion=CStr(Request.QueryString("ac"))
producto=CInt(Request.QueryString("prod"))
cant=CInt(Request.QueryString("cant"))
Select Case accion
Case "ver"
MostrarCarrito
Case "meter"
MeterArticulo Producto
MostrarCarrito
Case "sacar"
Call SacarArticulo (producto, cant)
MostrarCarrito
Case "fin"
PasarPorCaja
Case Else
MostrarCatalogo
End Select
Set Session("carrito")=carrito
oConn.Close
Set oConn=Nothing
%>


La zona donde tengo que meter el formulario y la recogida de datos es esta:

Sub PasarPorCaja'***********************************************************

%>
</H2>
<H2 class="Precios">¡Gracias por su compra!</H2>
<span class="Productos">
<%
MostrarCarrito
%>


<%
Set Session("carrito")=Nothing


Espero vuestra respuestaaa!!!


Un saludo!

Por bui3

71 de clabLevel



Genero:Masculino  

opera
Citar            
MensajeEscrito el 18 Mar 2008 10:45 am
Mmm ... me parece que este es el foro de software libre, tendrías que ponerlo en el de ASP

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 18 Mar 2008 12:38 pm
No existe un foro en cristalab que sea de asp...sino lo pondria...pero vamos...

Ayuda!

saludossss.....

Por bui3

71 de clabLevel



Genero:Masculino  

opera

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.