Example #1
0
    if (isset($_GET['id'])) {
        $user = new user($_SESSION['uid']);
        $totalPrice = $order->OrdersPrice($_SESSION['uid']);
        $product = new Product($_GET['id']);
        $order = new Order();
        $reminder = $user->credite - ($totalPrice['sum'] + $product->price);
        if ($reminder >= 0) {
            $order->user_id = $_SESSION['uid'];
            $order->num_items = $order->num_items + 1;
            $order->desc = $product->descr;
            $order->total_price = $product->price;
            $order->pid = $_GET['id'];
            $order->insert();
            // $Q=$product->quantity - $_session['quentity'];
            $Q = $product->quantity - 1;
            $product->updateQ($Q);
            $totalPrice = $order->OrdersPrice($_SESSION['uid']);
            $_SESSION['sum'] = $totalPrice['sum'];
        } else {
            //make pop up window to show that user don`t have enough credite
            echo "<script>alert('sorry,You don\\'t have enough credit.')</script>";
        }
    }
    $demand = $order->userOrder($_SESSION['uid']);
    //updateCart(count($demand));
}
?>
	 
<html>
	<head>
		<title>Shopping Cart</title>