Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created October 24, 2010 04:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilleiguaran/643086 to your computer and use it in GitHub Desktop.
Save guilleiguaran/643086 to your computer and use it in GitHub Desktop.
Carrito de Compras Simple
<?php
/* se recupera el carrito de la variable de sesión */
$carrito = $_SESSION['carrito'];
/* acá se harian las operaciones de agregar/quitar del carrito */
/* se guardan las modificaciones en la variable de sesión */
$_SESSION['carrito'] = $carrito;
?>
<html>
...
<table>
<th>
<td>ID</td>
<td>Cantidad</td>
</th>
<?php
/* Se recorre los item del carrito y se muestran */
foreach($carrito as $id => $cantidad)
{
?>
<tr>
<td><?php print $id; ?></td>
<td><?php print $cantidad; ?></td>
</tr>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment