I have a problem when sending purchase data by mail, I use an array to add it to the shopping cart

0
public function enviarCarrito()
{
    $xResponse = new Response(); 
    $carrito=(isset($_SESSION['carrito']));
    $body = "Detalle de Pedido \n" ;
    foreach($carrito as $elemento) //me marca error en el foreach
    {
        $Producto= new Producto($elemento); 
        $body .= "Nombre: " .  $elemento->nombre  . "\n";
        $body .= "Precio: " .  $elemento->precio  . "\n";
        $body .= "Periodo: " .  $elemento->periodicidad . "\n";
    }
    //$cantidad = $val['cantidad'];  
    $from="[email protected]"; //cuenta que envia 
    $sdestinatario="[email protected]"; //cuenta destino 
    $ssubject="Compra de Productos"; //subject 
    $header="From:".$from."\nReply-To:".$from."\n"; 
    $header=$header."X-Mailer:PHP/".phpversion()."\n"; 
    $header=$header."Mime-Version: 1.0\n"; 
    $header=$header."Content-Type: text/html"; 
    $enviado= mail($sdestinatario, utf8_decode($body),$ssubject,$header);
    if ($enviado)
    {
    $xResponse->script("toastr.success('En breve contestaremos su requerimiento')"); 
    $xResponse->script('parent.location.reload()');
    }
    else
    {
    $xResponse->script("toastr.error('Lo sentimos, datos no enviados')");
    //$xResponse->script('parent.location.reload()');
    }
    return $xResponse;
}
    
asked by Cheke Sanchez 30.01.2017 в 19:16
source

0 answers