-
Notifications
You must be signed in to change notification settings - Fork 0
/
mybasket.php
57 lines (51 loc) · 1.94 KB
/
mybasket.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
<?php
session_start();
include_once("connect.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Basket</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id = "products-wrapper">
<header>
<?php include_once("nav.php"); ?>
</header>
<br /><br /><br />
<div class="shopping-cart">
<h2>My Basket</h2>
<?php
$current_url = base64_encode($_SERVER['REQUEST_URI']);
if(isset($_SESSION["products"]))
{
$total = 0;
echo '<ol>';
foreach ($_SESSION["products"] as $cart_itm)
{
$product_code = $cart_itm["code"];
$result = $mysqli->query("SELECT id, product_img_name FROM products WHERE product_code = '$product_code' LIMIT 1"); // to display image. it is important to get id as well to retrieve image.
$obj = $result->fetch_object();
echo '<li class="cart-itm">';
echo '<a href = "display_each_product.php?id='.$obj->id.'"><img src="uploads/'.$obj->product_img_name.'">';
echo '<span class="remove-itm"><a href="cart_update.php?removep='.$cart_itm["code"].'&return_url='.$current_url.'">Remove</a></span>';
echo '<h3>'.$cart_itm["name"].'</h3>';
echo '<div class="p-code">P code : '.$cart_itm["code"].'</div>';
echo '<div class="p-qty">Qty: '.$cart_itm["qty"].'</div>';
echo '<div class="p-price">Price: '.$currency.$cart_itm["price"].'</div>';
echo '</li>';
$subtotal = ($cart_itm["price"]*$cart_itm["qty"]);
$total = ($total + $subtotal);
}
echo '</ol>';
echo '<span class="check-out-txt"><strong>Total : '.$currency.$total.'</strong> <a href="view_cart.php">Check-out!</a></span>';
echo '<span class="empty-cart"><a href="cart_update.php?emptycart=1&return_url='.$current_url.'">Empty Cart</a></span>';
}else{
echo 'Your shopping basket is empty';
}
?>
</div><!--shopping-cart end-->
<!--</div>-->
</body>
</html>