0
how do I stop at the pagseguro he pick up all the products added at my checkout and pass to the of the pagseguro he is only passing 1 product does not pick up all that are at my checkout how can I do this?
php code:
if(count($_SESSION['carrinho']) == 0){
echo '<tr><td colspan="5">Não há produto no carrinho</td></tr>';
}else{
require("conexao.php");
$a = new Conexao();
$a->conecta();
$total = 0;
foreach($_SESSION['carrinho'] as $id => $qtd){
$sql = "SELECT * FROM produtos WHERE id_produto= '$id'";
$qr = mysql_query($sql) or die(mysql_error());
$ln = mysql_fetch_assoc($qr);
$nome = $ln['nome'];
$preco = $ln['preco'];
$sub = $ln['preco'] * $qtd;
$img = $ln['img'];
$desc = $ln['descricao'];
$id = $ln['id_produto'];
$total += $ln['preco'] * $qtd;
print"
<tr>
<td class=\"cart_product\">
<a href=\"\"><img src=\"images/shop/$img\" alt=\"\" width=\"100px\" height=\"100px\"></a>
</td>
<td class=\"cart_description\">
<h4><a href=\"\">$nome</a></h4>
</td>
<td class=\"cart_price\">
<p>R$ $preco</p>
</td>
<td class=\"cart_quantity\">
<div class=\"cart_quantity_button\">
<input class=\"cart_quantity_input\" type=\"text\" name=\"prod['$id']\" value=\"$qtd\" autocomplete=\"off\" size=\"2\">
</div>
</td>
<td class=\"cart_total\">
<p class=\"cart_total_price\">R$ $sub</p>
</td>
<td class=\"cart_delete\">
<a class=\"cart_quantity_delete\" href=\"?acao=del&id=$id\"><i class=\"fa fa-times\"></i></a>
</td>
</tr>";
}
$total = number_format($total, 2, ',', '.');
echo '<tr>
<td colspan="4" class="cart_price">Total</td>
<td>R$ '.$total.'</td>
</tr>';
}
part of the form:
<form target="pagseguro" method="post" action="https://pagseguro.uol.com.br/checkout/checkout.jhtml">
<input type="hidden" name="email_cobranca" value="[email protected]">
<input type="hidden" name="tipo" value="CP">
<input type="hidden" name="moeda" value="BRL">
<input type="hidden" name="item_id_1" value="<?php echo $id; ?>">
<input type="hidden" name="item_descr_1" value="<?php echo $nome; ?>">
<input type="hidden" name="item_quant_1" value="1">
<input type="hidden" name="item_valor_1" value="<?php echo $total; ?>">
<input type="hidden" name="item_frete_1" value="0">
<input type="hidden" name="item_peso_1" value="1000">
<input type="submit" class="btn btn-default check_out" value="Finalizar Compra">
</form>