Skip to content

Instantly share code, notes, and snippets.

@jonataa
Last active December 24, 2015 15:55
Show Gist options
  • Select an option

  • Save jonataa/f2e627a206bf8d5ee388 to your computer and use it in GitHub Desktop.

Select an option

Save jonataa/f2e627a206bf8d5ee388 to your computer and use it in GitHub Desktop.
if ($_GET['acao'] == 'add') {
$id = intval($_GET['id']);
if (!isset($_SESSION['ticket'][$id])) {
$_SESSION['ticket'][$id] = array(
'qtd' => 1,
'item' => "X-frango",
'preco' => 10.00,
'subtotal' => 10.00 * 1
);
} else {
$_SESSION['ticket'][$id]['qtd'] += 1;
$_SESSION['ticket'][$id]['subtotal'] = $_SESSION['ticket'][$id]['preco'] * $_SESSION['ticket'][$id]['qtd'];
}
$_SESSION['carrinho']['subtotal'] = 0;
foreach ($_SESSION['ticket'] as $produto) {
$_SESSION['carrinho']['subtotal'] += $produto['subtotal'];
}
$entrega = 5;
$_SESSION['carrinho']['total'] = $_SESSION['carrinho']['subtotal'] + $entrega;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment