-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
75 lines (62 loc) · 1.37 KB
/
cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
include('models.php');
include('functions.php');
?>
<?php
function cart(){
if(!isset($_SESSION['cart'])) return;
$cart = $_SESSION['cart'];
function display_cart($cart){
foreach($cart->items as $index => $booking){
$session = SessionModel::get('id',$booking->session_id);
$movie = MovieModel::get('id',$session->movie_id);
render('cart_item.php',array(
'item_number' => $index,
'movie' => $movie,
'session' => $session,
'booking' => $booking
));
}
}
if(isset($_GET['action'])){
switch ($_GET['action']){
case 'destroy':
echo $_GET['action'];
$cart->items=array();
//$_SESSION['cart']=$cart;
break;
case 'delete_item':
$cart->delete_item(intval($_GET['i']));
header( 'Location: cart.php' ) ;
exit();
break;
}
}
display_cart($cart);
echo "Total: \$".number_format($cart->total,2);
};
?>
<?php include_once('header.php'); ?>
<div id="box">
<div class="box2">Shopping Cart Review</div>
<?php cart(); ?>
<hr />
<?php
if(isset($_SESSION['customer_info'])){
$c = $_SESSION['customer_info'];
render('customer_info.php',array(
'name' => $c->name,
'email' => $c->email,
'phone' => $c->phone
));
}
else{
render('customer_info.php',array(
'name' => '',
'email' => '',
'phone' => ''
));
}
?>
</div>
<?php include_once('footer.php'); ?>