Ver Mensaje Individual
  #15 (permalink)  
Antiguo 15/04/2005, 12:05
Gux
 
Fecha de Ingreso: octubre-2003
Mensajes: 58
Antigüedad: 20 años, 6 meses
Puntos: 0
Esto es exactamente lo que llega por mail cuando hago el envio:

Código:
Para un pedido de un artículo:

Familia: Array[0]   Referencia: Array[0]   Artículo: Array[0].....

Para un pedido de dos artículos:

Familia: Array[1]   Referencia: Array[1]   Artículo: Array[1].....

Para un pedido de tres artículos:

Familia: Array[2]   Referencia: Array[2]   Artículo: Array[2].....

etc, etc...
Si no estoy equivocado los números entre los [] hacen referencia al id del producto, lo que quiere decir que los datos que muestra corresponden al último producto que se ha añadido al pedido... lo que a su vez significa que no hace el bucle... ¿estoy equivocado?

Me he leido el tema de foreach, el if_array, he consultado manuales... pero lo único que he conseguido ha sido liarme más. Sólo me falta que se envie el pedido para terminar este trabajo... necesito que alguien me eche un cable gordo, por favor.

Adjunto los codigos clave (como los tengo actualmente):

funcion para mostrar los datos:

Código PHP:
//Muestra el contenido del carrito para el mail
    
function imprime_carro(){

    
             for (
$i=0;$i<$this->num_productos;$i++){
            if(
$this->array_id_prod[$i]!=0){

                if(
$this->array_familia_prod[$i]=='Material Oficina')
                {

          if(
$this->array_cantidad_prod[$i]<=1)
                {
                    
$descuento='0';
                }
                else if(
$this->array_cantidad_prod[$i]>=and $this->array_cantidad_prod[$i]<=4)
                {
                    
$descuento='2';
                }
                else if(
$this->array_cantidad_prod[$i]>=and $this->array_cantidad_prod[$i]<=9)
                {
                    
$descuento='4';
                }
                else if(
$this->array_cantidad_prod[$i]>=10 and $this->array_cantidad_prod[$i]<=18)
                {
                    
$descuento='8';
                }
                else if(
$this->array_cantidad_prod[$i]>=19 and $this->array_cantidad_prod[$i]<=24)
                {
                    
$descuento='10';
                }
                else if(
$this->array_cantidad_prod[$i]>=25 and $this->array_cantidad_prod[$i]<=35)
                {
                    
$descuento='11';
                }
                else if(
$this->array_cantidad_prod[$i]>=36)
                {
                    
$descuento='15';
                }

                }
                else
                {
                
                
$descuento='0';
                }

        
$html"<tr>
                 <td class='txt3p' height='30'> $this->array_familia_prod[$i] </td>
                 <td class='txt3p' height='30'> $this->array_producto_prod[$i] </td>
                 <td class='txt3p' height='30'> $this->array_referencia_prod[$i] </td>
                 <td class='txt3p' height='30'> $this->array_articulo_prod[$i] </td>
                 <td class='txt3p' height='30' align='center'> $this->array_precio_prod[$i] </td>
                 <td class='txt3p' height='30' align='center'> $this->array_cantidad_prod[$i] </td>
                 <td class='txt3p' height='30'><center>$descuento %</center></td>"
;

                
$rebaja $descuento/100;
                
$desc =  $this->array_precio_prod[$i]*$this->array_cantidad_prod[$i]*$rebaja;
                
$importe round($this->array_precio_prod[$i]*$this->array_cantidad_prod[$i]-$desc,2);


         
$html .="<td class='txt3p' height='30'><center>$importe €</center></td>
                </tr>
                <tr>
                <td height='10' class='px' colspan='9'>
                </td>
                </tr>
                <tr>
                 <td width='545' bgcolor='#164D89' height='1' class='px' colspan='9'>
                 </td>
                </tr>"
;
            }
        }

        return 
$html

    } 
pagina de envio con llamada a la funcion:

Código PHP:
<?php
include("lib_carrito.php");

if(!
$_SESSION[auth]) 
{
header("Location: index.php");
exit; 
}

$sfrom="$email"//cuenta que envia
$sdestinatario="info@micorreo"//cuenta destino
$ssubject="Pedido desde la página web"//subject
$shtml="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<title>Pedido desde la página web</title>
<style>
.txt{
font-family: arial;
font-size: 9px;
color: '#444444';
}
.tit{
font-family: arial;
font-size: 11px;
color: '#444444';
font-weight: bold;
padding-left: 5px;
padding-right: 5px;
}
</style>
<link rel='stylesheet' href='http://www.buraltec.com/estilos.css' type='text/css'>
</head>
<body bgcolor='#E0E4EC' marginwidth='0' marginheight='0' topmargin='40' leftmargin='0'>
 <table align='center' bgcolor='ffffff' width='771' border='0' cellspacing='0' cellpadding='0'>
  <tr>
   <td colspan='2' class='a11gr' height='80'><center><font color='#357EB5'><u>HA RECIBIDO EL SIGUIENTE PEDIDO DESDE LA PÁGINA WEB</u></font></center>
   </td>
  </tr>
  <tr>
   <td valign='top' width='40%' height='200' align='center'><img src='http://www.uvedoblestudio.com/img/cereza.jpg' width='150' height='200'>
   </td>
   <td valign='top' class='tit'><u>ENVÍA:</u><br><br><br><span class='txt'><b>Empresa:</b> $empresa<br><br><b>CIF:</b> $cif<br><br><b>Nombre:</b> $nombre<br><br><b>Dirección:</b> $direccion - $municipio [ $provincia ]<br><br><b>Tlfno.:</b> $telefono - <b>Fax:</b> $fax<br><br><b>E-mail:</b> $email</span><br><br><br><u>PEDIDO:</u><br><br>
   </td>
  </tr>
  <tr>
   <td valign='top' colspan='2' class='px'>
   </td>
  </tr>
  <tr>
   <td valign='top' colspan='2' class='txt'>
    <table cellspacing='0' cellpadding='0' border='0'>
     <tr>
      <td width='711' bgcolor='#164D89' height='1' class='px' colspan='9'>
      </td>
     </tr>
     <tr>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='110'>Familia
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='90'>Producto
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='80'>Referencia
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='177'>Artículo
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='70' align='center'>Precio
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='30' align='center'>Cantidad
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='40' align='center'>Descuento
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='80' align='center'>Importe
      </td>
      <td class='t9bl' bgcolor='#557FD7' height='20' width='20' align='center'>Eliminar
      </td>
     </tr>
     <tr>
      <td width='711' bgcolor='#164D89' height='1' class='px' colspan='9'>
      </td>
     </tr>
     <tr>
      <td height='10' class='px' colspan='8'>
      </td>
     </tr>
     <tr>
      <td width='711' bgcolor='#164D89' height='1' class='px' colspan='9'>
      </td>
     </tr>"
;

    
$shtml .= $_SESSION["ocarrito"]->imprime_carro();

    
$shtml .="</table>
   </td>
  </tr>
  <tr>
   <td valign='top' colspan='2' height='30'>
   </td>
  </tr>
 </table>
</body>
</html>
"
//mensaje
$sheader="From:".$sfrom."\nReply-To:".$sfrom."\n";
$sheader=$sheader."X-Mailer:PHP/".phpversion()."\n";
$sheader=$sheader."Mime-Version: 1.0\n";
$sheader=$sheader."Content-Type: text/html";
mail($sdestinatario,$ssubject,$shtml,$sheader);


if(
mail)
    { echo(
"bien"); } else { echo("mal") }
?>