示例#1
0
<?php

require_once 'lib/dblibs.php';
require_once 'lib/lib.php';
if (array_key_exists('loggedin', $_SESSION)) {
    db_connect();
    $user_id = db_get_user_id($_SESSION['loggedin']);
    $product = db_get_product_by_id($_POST['product']);
    $product_id = $product['item#'];
    $qtd = user_has_in_the_cart($user_id, $product_id);
    if ($qtd > 0) {
        $qtd = $qtd + $_POST['qtd'];
        db_update_cart($user_id, $product_id, $qtd);
    } else {
        db_add_to_cart($user_id, $product_id, $_POST['qtd']);
    }
    header("Location: cart_page.php");
} else {
    output_html5_header('Edit Product', array("bootstrap/css/bootstrap.css", "bootstrap/css/bootstrap-theme.css", "css/style.css"), array("js/jquery.min.js", "bootstrap/js/bootstrap.min.js"));
    message("bad", " You must be logged in to do this! <a href=\"login.php\">Log in</a>");
    output_page_footer();
    output_html5_footer();
}
示例#2
0
<?php 
require_once 'lib/lib.php';
require_once 'lib/dblibs.php';
$product = db_get_product_by_id($_GET['id']);
output_html5_header("Product", array("bootstrap/css/bootstrap.css", "bootstrap/css/bootstrap-theme.css", "css/style.css"), array("js/jquery.min.js", "bootstrap/js/bootstrap.min.js"));
output_page_menu();
?>

<h1><?php 
echo $product['brand'] . ' ' . $product['name'];
?>
</h1>

<div class="row">
	<div class="col-md-4">
		<div class="img">
			<img class="img-responsive"  src="<?php 
echo $product['image'];
?>
" />
		</div>
	</div>
	
	<div class="col-md-6">
		<div class="description">
			<p><strong>Description: </strong><?php 
echo $product['description'];
?>
</p>
			<p><strong>Colour: </strong><?php 
echo $product['colourway'];
示例#3
0
	<thead>
		<th>Product</th>
		<th></th>
		<th>Price</th>
		<th>Quantity</th>
	</thead>
	<tbody>
	<?php 
    $i = 0;
    $s = 's';
    $subtotal = 0;
    if ($cart != NULL) {
        $i = 0;
        $s = 's';
        foreach ($cart as $prod) {
            $product = db_get_product_by_id($prod['item#']);
            $subtotal = total($cart);
            $quantity = $prod['quantity'];
            ?>
			<tr>
				<td><img class="sml" src="<?php 
            echo $product['image'];
            ?>
"/></td>
				<td>
					<h4><?php 
            echo $product['brand'] . ' ' . $product['name'];
            ?>
</h4>
					<p><?php 
            echo $product['brand'];
示例#4
0
function total($cart)
{
    $subtotal = 0;
    foreach ($cart as $prod) {
        $product = db_get_product_by_id($prod['item#']);
        $quantity = $prod['quantity'];
        $subtotal = $subtotal + $product['price'] * $quantity;
    }
    return $subtotal;
}