¿Cuál podría ser el problema? A continuación os dejo el código de los diferentes archivos que influyen en dicho proceso.
Archivo cestas_detalle.asp
Código:
Archivo carro_insertar.asp<%
response.codepage=1252
if Trim(ficha("foto1"))="" then
img="sinfoto.png"
else
img=Trim(ficha("foto1"))
end if%>
<h1 class="centro ancho"><span class="negro">CESTA <%=UCASE(ficha("nom_categoria"))%></span>
- <%=UCASE(ficha("nom_cesta"))%></h1>
<a href="images/fotos/<%=img%>" class="ampliada"><img src="images/fotos/<%=img%>" width="448" height="337" alt="CESTA <%=UCASE(ficha("nom_categoria"))%>- <%=ficha("nom_cesta")%>" border="0"/></a>
<div class="fotoscomp">
<!-- Nuria: esta división es la que he añadido para los porductos complementarios -->
<table summary="Listado de Noticias">
<caption>
<h3 style="font-size:14px;"><span class="granate">Quiero añadir a mi cesta</span></h3>
</caption>
<thead>
<tr>
<th><p style="font-size:12px;">Seleccionar:</p> </th>
<th><p></p></th>
<th><p></p></th>
</tr>
</thead>
<tbody>
<FORM METHOD=POST ACTION="carro_insertar.asp" name="formu" id="formu">
<INPUT TYPE="hidden" NAME="produ1" value="<%=Trim(ficha("nom_cesta"))%>|<%=Trim(ficha("precio"))%>">
<INPUT TYPE="hidden" NAME="id1" value="<%=Trim(ficha("Id_cesta"))%>">
<%
Function ConvertFromUTF8(sIn)
Dim oIn
Set oIn = CreateObject("ADODB.Stream")
oIn.Open
oIn.CharSet = "WIndows-1252"
oIn.WriteText Sin
oIn.Position = 0
oIn.CharSet = "UTF-8"
ConvertFromUTF8 = oIn.ReadText
oIn.Close
End Function
Id_cesta=Request.QueryString("id")
set listado=server.CreateObject("ADODB.recordset")
SQL="SELECT Id_asociacion,titulo,foto,precio,descripcion FROM asociaciones,productos where asociaciones.Id_producto=productos.Id_producto and asociaciones.Id_cesta= " & Id_cesta & " ORDER BY titulo "
listado.open SQL, STRING_flor, 1, 3
n=2
While Not listado.eof
titulo=listado("titulo")
precio=FormatNumber(listado("precio"),2)
precio=Replace(precio,".",",")
descripcion=listado("descripcion")
titulo=ConvertFromUTF8(titulo)
descripcion=ConvertFromUTF8(descripcion)
%>
<tr>
<td><input type="checkbox" name="ch<%=n%>" onClick="if(this.checked==true){produ<%=n%>.value='<%=titulo&"|"&precio%>'}else{produ<%=n%>.value=''}">
<INPUT TYPE="hidden" NAME="produ<%=n%>"> </td>
<td> <img src="GESTION/FotosProductosCom/<%=listado("foto")%>" width="150" height="100" alt="" /></td>
<td><h3><%=titulo%></h3>
<br/> <%=descripcion%><br/> <strong>P.V.P: <span class="granate"><%=precio%> €
</span></strong> </td>
<!-- el coste de lo que seleccionen debe añadirse al coste del carro de la compra, por ejemplo
si seleccionan una cesta y café, aparece en el carrito, la cesta, el café y el coste de cada uno y sumado añ final en la tabla
DEben de poder subir la foto, el titular, la descripción y el precio -->
</tr>
<%
n=n+1
listado.movenext
Wend
%>
<INPUT TYPE="hidden" NAME="contprodu" value="<%=n-1%>">
</FORM></tbody>
</table>
</div>
</div>
<div class="segundo">
<div class="descripcion">
<div class="texto detalles2">
<p><%=Trim(ficha("descripcion"))%></p>
<strong class="granate">MEDIDAS:</strong> <strong><%=ficha("medidas")%></strong>
</div>
<div class="limpio"></div>
<div class="detallesmas">
<%precio=FormatNumber(ficha("precio"),2)
precio=Replace(precio,".",",")&" €"%>
<div class="detalle1"><strong>P.V.P:<span class="granate"> <%=precio%></span></strong></div>
<div class="detalle2">
<div class="detalles3"><a href="javascript:document.getElementById('formu').submit();"><img type="image" src="images/carro.jpg" alt="Comprar" /></a></div>
</div>
</div>
<div class="limpio"></div>
<div class="fotos">
<p><img src="images/ver-detalles.jpg" alt="Ver detalles" /></p>
</div>
<div class="fotosb">
<%Dim imagenes(8)
For i=1 to 8
if ficha("foto"&i)<>"" then
imagenes(i)=Trim(ficha("foto"&i))
else
imagenes(i)="sinfoto.png"
end if
Next%>
<div class="limpio detalles4"> </div>
<%For i=1 to 8%>
<div class="ces14">
<%if Trim(imagenes(i))<>"sinfoto.png" then%>
<a href="images/fotos/<%=imagenes(i)%>" alt="Detalles de la cesta" class="ampliada"><img src="images/fotos/<%=imagenes(i)%>" alt="CESTA <%=UCASE(ficha("nom_categoria"))%>- <%=ficha("nom_cesta")%>" width="100" height="65"/></a>
<%else%>
<img src="images/fotos/sinfoto.png" alt="CESTA <%=UCASE(ficha("nom_categoria"))%>- <%=ficha("nom_cesta")%>" width="100" height="65"/>
<%end if%>
</div>
<%Next%>
Código:
Archivo carro_mostra1.asp<%
If session("num_prod")="" then
session("num_prod")=0
End if
session.codepage=1252
conta=request.Form("contprodu")
For n=1 To conta
If request.Form("produ" & n)<>"" Then
session("num_prod")= session("num_prod") +1
session("id" &session("num_prod"))=request.Form("id1")
session("linea" & session("num_prod"))=session("num_prod")
arra = Split(request.Form("produ" & n), "|")
session("nombre" & session("num_prod"))=arra(0)
session("precio" & session("num_prod"))=arra(1)
If session("cantidad"& session("num_prod"))="" then
session("cantidad"& session("num_prod"))=1
End if
End if
Next
response.redirect("carro_mostrar1.asp")
Sub borra_producto(i)
session("producto" & i) = 0
End Sub
%>
Código:
El orden de ejecución de los archivos es: se realiza el pedido en cestas_detalle.asp, desde el formulario se pasa la información a carro_insertar.asp y el carro de la compra se muestra en carro_mostrar1.asp.<%
Function ConvertFromUTF8(sIn)
Dim oIn
Set oIn = CreateObject("ADODB.Stream")
oIn.Open
oIn.CharSet = "WIndows-1252"
oIn.WriteText Sin
oIn.Position = 0
oIn.CharSet = "UTF-8"
ConvertFromUTF8 = oIn.ReadText
oIn.Close
End Function
If request.querystring("tipo") = 1 then
For a=1 To session("num_prod")
session("cantidad"&a)=request.Form("cantidad" &a)
Next
response.redirect("carro_mostrar1.asp")
End if
%>
<FORM id="formu" name="formu" METHOD=POST ACTION="carro_mostrar1.asp?tipo=1" >
<table style="margin-top:30px;" cellpadding="0" cellspacing="0" align="center" width="773" border="1" bordercolor="#CCCCCC">
<tr>
<th width="328" height="32" align="center" bgcolor="#eeac4d"><strong>CESTA</strong></th>
<th width="104" align="center" bgcolor="#eeac4d"><strong>CANTIDAD</strong></th>
<th width="95" align="center" bgcolor="#eeac4d"><strong>PRECIO</strong></th>
<th width="121" align="center" bgcolor="#eeac4d"><strong>SUBTOTAL</strong></th>
<th width="123" align="center" bgcolor="#eeac4d"><strong>ELIMINAR</strong></th>
</tr>
<%
For a=1 To session("num_prod")
If session("linea"&a)<>0 then
subtotal=(session("precio"&a))*(session("cantidad"&a))
%>
<tr>
<td height="28" align="center"><%=(session("nombre"&a))%></td>
<td align="center"><INPUT TYPE="text" NAME="cantidad<%=a%>" value="<%=session("cantidad"&a)%>" size="5" style="text-align:right"></td>
<td align="center"><%=FormatNumber(session("precio"&a),2)%> €</td>
<td align="center"><%=FormatNumber(subtotal,2)%> €</td>
<td align="center"><A HREF="carro_eliminar.asp?id=<%=session("linea"&a)%>"><img src="images/eliminar.jpg" width="48" height="15" alt=""/></a></td>
</tr>
<%
total=total + subtotal
End if
Next
%>
<tr>
<td height="28" colspan="6" align="right" class="textog">El precio total I.V.A. incluido al que asciende su compra es de <%=FormatNumber(total,2)%> €
<%
session("totalCompra")=FormatNumber(total,2)
%>
La base de datos es un archivo de access y hemos comprobado que este todo bien.
la url de la página para que hagis las pruebas es: http://www.florfruitseventos.com/cestas.asp, una vez allí se entra en una de las categorías y se compra una de las cestas añadiendo algún producto extra.


