Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde pessoal,
estou com um problema e ja nao sei como resolver.
Tenho uma pagina shopping cart, feita por action ajax, uma pagina html com um form post, e uma pagina para envio do email.
Nesta pagina de envio, consigo imprimir as infos do form, porem as infos do shopping cart so consigo fazer que aparecam no navegador pelo require_once('ajax-action.php');
preciso que esse shopping cart seja enviado para um email junto com as infos do form.
Segue o codigo do post do form
<?php
$destinatario = "ti@pdmg.com.br";
$nome = $_POST['nome'];
$email = $_POST['email'];
$unidade = $_POST['unidade'];
$telefone = $_POST['telefone'];
// monta o e-mail na variavel $body
$body = "===================================" . "\n";
$body = $body . "PEDIDO ONLINE - SNIPER FRANQUIA" . "\n";
$body = $body . "===================================" . "\n\n";
$body = $body . "Nome: " . $nome . "\n";
$body = $body . "Email: " . $email . "\n";
$body = $body . "Telefone: " . $telefone . "\n";
$body = $body . "Unidade: " . $unidade . "\n\n";
$body = $body . "===================================" . "\n";
echo nl2br($body);
require_once('ajax-action.php');
?>
E essa é a funcao do shopping cart
<?php
session_start();
require_once ("Product.php");
$product = new Product();
$productArray = $product->getAllProduct();
if(!empty($_POST["action"])) {
switch($_POST["action"]) {
case "add":
if(!empty($_POST["quantity"])) {
$productByCode = $productArray[$_POST["code"]];
$itemArray = array($productByCode["code"]=>array('name'=>$productByCode["name"], 'code'=>$productByCode["code"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode["price"]));
if(!empty($_SESSION["cart_item"])) {
$cartCodeArray = array_keys($_SESSION["cart_item"]);
if(in_array($productByCode["code"],$cartCodeArray)) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($productByCode["code"] == $k) {
$_SESSION["cart_item"][$k]["quantity"] = $_SESSION["cart_item"][$k]["quantity"]+$_POST["quantity"];
}
}
} else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray);
}
} else {
$_SESSION["cart_item"] = $itemArray;
}
}
break;
case "remove":
if(!empty($_SESSION["cart_item"])) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($_POST["code"] == $k)
unset($_SESSION["cart_item"][$k]);
if(empty($_SESSION["cart_item"]))
unset($_SESSION["cart_item"]);
}
}
break;
case "empty":
unset($_SESSION["cart_item"]);
break;
}
}
?>
<?php
if(isset($_SESSION["cart_item"])){
$item_total = 0;
?>
<table class="tutorial-table" name="tutorial-table">
<tbody>
<tr>
<th><strong>Nome</strong></th>
<th><strong>Codigo</strong></th>
<th class="align-right"><strong>Quantidade</strong></th>
<th class="align-right"><strong>Preço Unitário</strong></th>
<th></th>
</tr>
<?php
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td><strong><?php echo $item["name"]; ?></strong></td>
<td><?php echo $item["code"]; ?></td>
<td align="right"><?php echo $item["quantity"]; ?></td>
<td align="right"><?php echo "R$".$item["price"]; ?></td>
<td align="center"><a onClick="cartAction('remove','<?php echo $item["code"]; ?>')" class="btnRemoveAction cart-action"><img src="images/icon-delete.png" /></a></td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
}
?>
<tr>
<td colspan="3" align=right><strong>Total:</strong></td>
<td align=right><?php echo "R$". number_format($item_total,2); ?></td>
<td></td>
</tr>
</tbody>
</table>
<?php
}
?>Carregando comentários...