0
I have this code that shows the results of the items in the cart
<?php
session_start();
require_once "functions/product.php";
require_once "functions/cart.php";
$pdoConnection = require_once "connection.php";
if(isset($_GET['acao']) && in_array($_GET['acao'], array('add', 'del', 'up'))) {
if($_GET['acao'] == 'add' && isset($_GET['id']) && preg_match("/^[0-9]+$/", $_GET['id'])){
addCart($_GET['id'], 1);
}
if($_GET['acao'] == 'del' && isset($_GET['id']) && preg_match("/^[0-9]+$/", $_GET['id'])){
deleteCart($_GET['id']);
}
if($_GET['acao'] == 'limpar'){
limpacart($_GET['id'], 1);
}
if($_GET['acao'] == 'up'){
if(isset($_POST['prod']) && is_array($_POST['prod'])){
foreach($_POST['prod'] as $id => $qtd){
updateCart($id, $qtd);
}
}
}
header('location: carrinho.php');
}
$resultsCarts = getContentCart($pdoConnection);
$totalCarts = getTotalCart($pdoConnection);
?>
How I could email items with Phpmailer?
// Instância do objeto PHPMailer
$mail = new PHPMailer;
$mail->CharSet = 'UTF-8';
$mail->SetLanguage("br");
$mail->Body = utf8_decode($body);
// Configura para envio de e-mails usando SMTP
$mail->isSMTP();
// Servidor SMTP
$mail->Host = 'mail.xxx.com.br';
// Usar autenticação SMTP
$mail->SMTPAuth = true;
// Usuário da conta
$mail->Username = '[email protected]';
// Senha da conta
$mail->Password = 'xxx@';
// Tipo de encriptação que será usado na conexão SMTP
$mail->SMTPSecure = 'ssl';
// Porta do servidor SMTP
$mail->Port = 465;
// Informa se vamos enviar mensagens usando HTML
$mail->IsHTML(true);
// Email do Remetente
$mail->From = '[email protected]';
// Nome do Remetente
$mail->FromName = $email_cart;
// Endereço do e-mail do destinatário
$mail->addAddress('[email protected]');
// Assunto do e-mail
$mail->Subject = 'xxxxx';
// Mensagem que vai no corpo do e-mail
$mail->Body = ' AQUI OS INTENS DO CARRINHO';
exit
Array ( [0] => Array ( [id] => 1906 [name] => GLVC 3100 [price] => [quantity] => 1 [subtotal] => 0 ) [1] => Array ( [id] => 1907 [name] => HDRC 3153 [price] => [quantity] => 1 [subtotal] => 0 ) [2] => Array ( [id] => 2385 [name] => HDN 01 [price] => [quantity] => 1 [subtotal] => 0 ) [3] => Array ( [id] => 2390 [name] => HDN 06 [price] => [quantity] => 1 [subtotal] => 0 ) [4] => Array ( [id] => 2392 [name] => HDN 08 [price] => [quantity] => 1 [subtotal] => 0 ) [5] => Array ( [id] => 2421 [name] => Santa Ceia [price] => [quantity] => 1 [subtotal] => 0 ) [6] => Array ( [id] => 2422 [name] => Tartaruga [price] => [quantity] => 1 [subtotal] => 0 ) [7] => Array ( [id] => 2423 [name] => Tijolo [price] => [quantity] => 1 [subtotal] => 0 ) [8] => Array ( [id] => 2451 [name] => Argamassa Refrataria [price] => [quantity] => 1 [subtotal] => 0 ) [9] => Array ( [id] => 2452 [name] => Massa Refrataria em saca [price] => [quantity] => 1 [subtotal] => 0 ) )
Welcome marelevou! Mate, put an example of the output of the search results of the cart. All you need to do is create your email message, would it just be written or HTML? ... To edit the question and add these details, click on edit below your question.
– rbz
Thanks @Rbz yes I just need to create an html with the cart items, how would I do? I edited the question with the output
– Wagner Martins Bodyboard