Ejemplo n.º 1
0
		<td width="40px" align="center">Preis(EUR)</td>
		<td colspan="2" width="200px">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="6">&nbsp;</td>
	</tr>
<?php 
/* load or initialize the ShoppingCart */
if (!isset($shopping_cart)) {
    if (isset($_SESSION["cart_product_id_array"])) {
        $shopping_cart = new ShoppingCart($_SESSION["username"], $_SESSION["cart_product_id_array"], $_SESSION["cart_product_amount_array"]);
    } else {
        $shopping_cart = new ShoppingCart($_SESSION["username"]);
    }
}
$list = $shopping_cart->getItems();
/* if there were any actions, set the focus to the next item */
$prev_edit_product_id = "";
$set_focus_next = false;
if (var_get_post("action", "") == "edit_product_amount") {
    $prev_edit_product_id = var_get_post("product_id", "");
}
for ($i = 0; $i < count($list); $i++) {
    echo "\t<tr class=\"list_normal\" onmouseover=\"javascript: this.className='list_hover';\" onmouseout=\"javascript: this.className='list_normal';\">\n";
    echo "\t<form name=\"edit_product_amount_" . $list[$i][0] . "\" action=\"shoppingcart.php\" method=\"POST\">\n";
    echo "\t<input type=\"hidden\" name=\"action\" value=\"edit_product_amount\">\n";
    echo "\t<input type=\"hidden\" name=\"product_id\" value=\"" . $list[$i][0] . "\">\n";
    echo "\t<input type=\"submit\" value=\"\" class=\"invisible_submit\">\n";
    echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=" . $list[$i][0] . "';\">" . $list[$i][0] . "</td>\n";
    echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=" . $list[$i][0] . "';\">" . $list[$i][1] . "</td>\n";
    echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=" . $list[$i][0] . "';\">" . $list[$i][4] . "</td>\n";
Ejemplo n.º 2
0
    case 'add':
        foreach ($products as $product) {
            if ($product['name'] == $name) {
                $cart->add($name);
                break;
            }
        }
        break;
    case 'empty':
        $cart->clear();
        break;
    case 'remove':
        $cart->remove($name);
        break;
}
$items = $cart->getItems();
if (!empty($items)) {
    echo '
		<table class="table">
		<tr>
			<td><b>Product</b></td>
			<td><b>Price</b></td>
			<td><b>Qty</b></td>
			<td><b>Total</b></td>
			<td></td>
		</tr>';
    $total = 0;
    foreach ($items as $name => $qty) {
        foreach ($products as $product) {
            if ($product['name'] == $name) {
                break;