-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_cart.php
212 lines (180 loc) · 7.03 KB
/
view_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<?php
session_start();
include_once "config.php";
?>
<html>
<head>
<title>INDEX</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#oferta > div:gt(0)").hide();
setInterval(function() {
$('#oferta > div:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#oferta');
}, 3000);
});
</script>
</head>
<body>
<div id="wrapper">
<div id=header>
<img id="header_image" src="images/logo.png">
<?php
if(isset($_SESSION["active_user"])){
echo $HTML =<<<HTML
<form id = "user_index" method="get" action="logout.php">
<p style="display:inline"><span style="color:#0e0e0e; font-size:115%; "> User < {$_SESSION["active_user"]["name"]} > </span> <b> | </b></p>
<a href ="logout.php?logout" style="font-size:115%;color:blue; "> Logout </a>
</form>
HTML;
}
?>
</div>
<div>
<div id="menu_tab">
<ul class="menu">
<li><a href="my_account.php" class="nav">My account</a></li>
<li class="divider"></li>
<li><a href=<?php
if(isset($_SESSION["active_user"]))
echo "# onclick=\"(alert('You Are Currently Logged In!'))\"; ";
else echo "register.php" ;
?>
class="nav">Register</a></li>
<li class="divider"></li>
<li><a href="index.php" class="nav">Products</a></li>
<li class="divider"></li>
<li><a href="view_cart.php" class="nav"> Cart </a></li>
<li class="divider"></li>
<li><a href="contact_us.php" class="nav">Contact Us</a></li>
</ul>
</div>
<!-- end of menu tab -->
<!------------------------------------------------------------------>
<div class="left_content">
<div class="title_box">Categories</div>
<link href="style.css" rel="stylesheet" type="text/css"/>
<ul class="left_menu">
<li class="odd"><a href="engine_parts.php"><b>Engine Parts</b></a></li>
<li class="even"><a href="braking_parts.php"><b>Braking Parts </b></a></li>
<li class="odd"><a href="exhaust_parts.php"><b>Exhaust Parts</b></a></li>
<li class="even"><a href="moto_parts.php"><b>Moto Accessories</b></a></li>
<li class="odd"><a href="gear_parts.php"><b>Protective Gear</b></a></li>
</ul>
<!-- end of left content -->
</div>
<?php
if(isset($_SESSION))
{
$total_prc = 0;$total_qty = 0;
if(isset($_SESSION["e-shop"]) && count($_SESSION['e-shop']>0))
{
$total_prc = Calc($_SESSION['e-shop'])['price'] ;
$total_qty = Calc($_SESSION['e-shop'])['qty'] ;
}
echo $HTML_ = <<<HTML
<div class="right_content">
<div class="border_box">
<form method="get" action="details.php">
<input type="text" name="search" value="Search..." maxlength="30" size = "12" >
<button> Search </button>
</form>
</div>
<form method="post" action="view_cart.php"
<div class="shopping_cart">
<div class="title_box">Shopping cart</div>
<div class="cart_details"> {$total_qty} items <br />
<span class="border_cart"></span> Total: <span class="price">{$total_prc}  {$currency}</span> </div>
<div class="cart_icon"><input type="image" src="images/shoppingcart.png"width="35" height="35" border="0" ></div>
</div>
</form>
</div>
HTML;
}
?>
<?php
function Calc(array $temp_array){
$tmp = array(
'price' => 0.0,
'qty' =>0.0,
);
foreach($_SESSION['e-shop'] as $prod_object)
{
for($i = 0 ; $i < intval($prod_object["product_qty"]);$i++)
{
$tmp['price'] = $tmp['price'] + floatval($prod_object["product_price"]);
}
$tmp['qty']= $tmp['qty'] + floatval($prod_object["product_qty"]);
}
return $tmp;
}
?>
<div class="center_content">
<div id="oferta" style="margin:5px 0 5px 0;">
<div>
<img src="images/image1.jpg" style="width:585px;">
</div>
<div>
<img src="images/image2.jpg" style="width:585px;">
</div>
</div>
<div class="center_prod_content">
<h1 class="center_heading"> Shopping Cart! </h1>
<div class="cart-view-table-back">
<form method="get" action="cart_update.php">
<!-- Return URL hidden value -->
<input type="hidden" name="return_url" value="view_cart.php">
<table width="100%" cellpadding="6" cellspacing="0"><thead><tr><th>Quantity</th><th>Name</th><th>Price</th><th>Remove</th></tr></thead>
<tbody>
<?php
if(isset($_SESSION["e-shop"])) //check session var
{
$total = 0; //set initial total value
$b = 0; //var for zebra stripe table
foreach ($_SESSION["e-shop"] as $cart_itm)
{
//set variables to use in content below
$product_name = $cart_itm["product_name"];
$product_qty = $cart_itm["product_qty"];
$product_price = $cart_itm["product_price"];
$product_code = $cart_itm["product_code"];
$subtotal = ($product_price * $product_qty); //calculate Price x Qty
$bg_color = ($b++%2==1) ? 'odd' : 'even'; //class for zebra stripe
echo '<tr class="'.$bg_color.'">';
echo '<td><input type="text" size="2" maxlength="2" name="product_qty['.$product_code.']" value="'.$product_qty.'" /></td>';
echo '<td>'.$product_name.'</td>';
echo '<td>'.$currency.$product_price.'</td>';
echo '<td><input type="checkbox" name="remove_code[]" value="'.$product_code.'" /></td>';
echo '</tr>';
$total = ($total + $subtotal); //add subtotal to total var
}
}
else $total = 0;
?>
<tr><td colspan="5"><span style="float:right;text-align: right;"><span style="color:gold ; padding:1px;font-size:115%;"> Amount Payable : <?php echo $total.' '. $currency?> </span></td></tr>
<tr><td colspan="5"><a href="index.php"><button type="button" style="" class="custom-button">Add Items</button></a> <input type="submit" style="float:right;margin-top:10px" value="Update" class="custom-button"></td></tr>
</tbody>
</table>
<input type="submit" name="ord_conf" style="float:center;margin:0; width:580px; height:22.5px;" value="Order Confirmation!" class="custom-button">
</form>
</div>
<!-- end of right content -->
</div>
<!-- end of main content -->
</div>
<div class="footer">
<div id="footer_logo"> HARIS MOTOS - All Rights Reserved 2015 </div>
</div>
</div>
</div>
<!-- end of main_container -->
</body>
</html>