-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeranjang.php
86 lines (79 loc) · 2.25 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
<?php
session_start();
include "admin/db/koneksi.php";
if(empty($_SESSION['keranjang']) || !isset($_SESSION['keranjang']))
{
echo "<script>
alert('Keranjang Belanja Anda Kosong! silahkan Belanja Dulu!!!');
document.location.href='index.php';
</script>";
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Keranjang Belanja</title>
<link rel="stylesheet" type="text/css" href="admin/assets/css/bootstrap.css">
</head>
<body>
<!-- navbar -->
<?php include "menu.php"; ?>
<!-- navbar -->
<!-- konten -->
<section class="konten">
<div class="container">
<h1>Keranjang Belanja</h1>
<hr>
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Nama Produk</th>
<th>Harga </th>
<th>Jumlah</th>
<th>Subtotal</th>
<th>Aksi</th>
</tr>
</thead>
<?php $no = 1; ?>
<?php foreach ($_SESSION['keranjang'] as $id_produk => $jumlah): ?>
<!-- menampilkan produk berdasarkan id_produk -->
<?php
$result = $koneksi->query("SELECT * FROM produk WHERE id_produk='$id_produk' ");
$produk = $result->fetch_assoc();
$subharga = $produk['harga_produk']*$jumlah;
?>
<tbody>
<tr>
<td><?= $no++; ?></td>
<td><?= $produk['nama_produk']; ?></td>
<td>Rp. <?= number_format($produk['harga_produk']); ?></td>
<td><?= $jumlah; ?></td>
<td>Rp. <?= number_format($subharga);?></td>
<th>
<a href="hapusKeranjang.php?id=<?= $id_produk; ?>" class="btn btn-danger">Hapus</a>
</th>
</tr>
</tbody>
<?php endforeach; ?>
</table>
<a href="index.php" class="btn btn-default">Lanjutkan Belanja</a>
<a href="checkout.php" class="btn btn-primary">Checkout</a>
</div>
</section>
<!-- konten -->
<!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
<!-- JQUERY SCRIPTS -->
<script src="admin/assets/js/jquery-1.10.2.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="admin/assets/js/bootstrap.min.js"></script>
<!-- METISMENU SCRIPTS -->
<script src="admin/assets/js/jquery.metisMenu.js"></script>
<!-- MORRIS CHART SCRIPTS -->
<script src="admin/assets/js/morris/raphael-2.1.0.min.js"></script>
<script src="admin/assets/js/morris/morris.js"></script>
<!-- CUSTOM SCRIPTS -->
<script src="admin/assets/js/custom.js"></script>
</body>
</html>