-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeranjang.php
175 lines (168 loc) · 6.38 KB
/
keranjang.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
<?php
session_start();
$koneksi = new mysqli("localhost","root","","grabook");
//Keranjang Kosong
if (empty($_SESSION['keranjang']) OR !isset($_SESSION['keranjang'])) {
echo "<script> alert('Keranjang Belanja Kosong, Silahkan Berbelanja'); </script>";
echo "<script> location='index.php'; </script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" type="text/css" href="css/index.css">
<style>
/* Tambahkan CSS kustom di sini */
body {
font-family: 'Poppins', sans-serif;
background-color: #ffffff;
color: #3440A8;
}
h1, h2, h3, h4, h5, h6 {
color: #3440A8;
}
.navbar, .footer {
background-color: #3440A8;
padding: 15px 0;
border-radius: 10px; /* Rounded corners */
}
.navbar-nav > li > a {
color: white;
font-size: 15px;
}
.navbar-nav > li > a:hover {
color: #FABA26 !important;
}
.btn-primary {
background-color: #3440A8;
border-color: #3440A8;
color: white;
}
.btn-warning {
background-color: #FABA26;
border-color: #FABA26;
color: #3440A8;
}
.btn-success {
background-color: #34A853;
border-color: #34A853;
color: white;
}
.btn-danger {
background-color: #EA4335;
border-color: #EA4335;
color: white;
}
.thumbnail {
height: 420px; /* Set a fixed height for all thumbnails */
}
.logo-big {
width: 250px; /* Atur lebar sesuai kebutuhan */
height: auto; /* Menjaga rasio aspek gambar */
margin-bottom: 0; /* Mengatur margin bawah jika perlu */
}
.navbar-brand {
display: flex;
align-items: center;
}
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg" style="background-color: #212529;">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand d-flex align-items-center" href="index.php">
<img class="me-2 logo-big" src="img/grab.png" alt="">
</a>
</div>
<ul class="nav navbar-nav">
<!-- Jika Sudah Login -->
<?php if (isset($_SESSION['pelanggan'])): ?>
<li><a href="logout.php" onclick="return confirm('Apakah Anda Yakin ?')" style="color: white;">Logout</a></li>
<li><a href="riwayat.php" style="color: white;">Riwayat</a></li>
<?php endif; ?>
</ul>
<ul class="nav navbar-nav navbar-right">
<?php if (!isset($_SESSION['pelanggan'])): ?>
<li>
<a href="login.php" class="btn btn-primary custom-button">Login</a>
</li>
<li><a href="daftar.php" style="color: white;">Daftar</a></li>
<?php endif; ?>
<li><a href="index.php" style="color:white;">Belanja</a></li>
<?php if(!isset($_SESSION["keranjang"])) : ?>
<li><a href="keranjang.php" style="color:white;">Keranjang<strong>(0)</strong></a></li>
<?php else : ?>
<hide>
<?php $jml=0; ?>
<?php foreach ($_SESSION["keranjang"] as $id_produk => $jumlah): ?>
<!-- Menampilkan Produk Perulangan Berdasarkan id_produk-->
<?php $ambildata = $koneksi->query("SELECT * FROM produk WHERE id_produk='$id_produk'"); ?>
<?php $pecah = $ambildata->fetch_assoc(); ?>
<tr>
<td><?php $jumlah ?></td>
</tr>
<?php $jml += $jumlah; ?>
<?php endforeach ?>
</hide>
<li><a href="rekomendasi.php" style="color: white;">Rekomendasi</a></li>
<li><a href="keranjang.php" style="color: white;">Keranjang<strong>(<?php echo $jml ?>)</strong></a></li>
<?php endif ?>
<li><a href="bayar.php" style="color:white;" >Pembayaran</a></li>
</ul>
<form action="pencarian.php" method="get" class="navbar-form navbar-right">
<input type="text" name="keyword" class="form-control" placeholder="Pencarian">
<button class="btn btn-primary custom-button">Cari</button>
</form>
</div>
</nav>
<!-- konten -->
<section class="konten">
<div class="container">
<h1><span><em class="glyphicon glyphicon-shopping-cart"></em> Keranjang Buku</span> </h1>
<hr>
<table class="table table-bordered ">
<thead>
<tr>
<th>No</th>
<th>Judul Buku</th>
<th>Harga</th>
<th>Jumlah</th>
<th>Total</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
<?php $nomor=1; ?>
<?php foreach ($_SESSION["keranjang"] as $id_produk => $jumlah): ?>
<!-- Menampilkan Produk Perulangan Berdasarkan id_produk-->
<?php $ambildata = $koneksi->query("SELECT * FROM produk WHERE id_produk='$id_produk'"); ?>
<?php $pecah = $ambildata->fetch_assoc(); ?>
<tr>
<td><?php echo $nomor; ?></td>
<td><?php echo $pecah['nama_produk']; ?></td>
<td>Rp. <?php echo number_format($pecah['harga_produk']); ?></td>
<td><?php echo $jumlah ?></td>
<td>Rp. <?php echo number_format($pecah['harga_produk']*$jumlah); ?></td>
<td>
<a href="hapuskeranjang.php?id=<?php echo $id_produk ?>" class="btn btn-danger btn-xs"
onclick="return confirm('Apakah Anda Yakin ?');">Hapus</a>
</td>
</tr>
<?php $nomor++; ?>
<?php endforeach ?>
</tbody>
</table>
<a href="index.php" class="btn btn-success">Lanjut Belanja</a>
<a href="bayar.php" class="btn btn-primary">Bayar</a>
<a href="hapuskeranjang.php?id=<?php echo $id_produk ?>" class="btn btn-danger"
onclick="return confirm('Apakah Anda Yakin ?');">Hapus Semua</a>
</div>
</section>
</body>
</html>