-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout.php
70 lines (67 loc) · 3.06 KB
/
checkout.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
<div id="container">
<div class="badan">
<h2>Check Out</h2>
<form action="transaction.php" method="post">
<div align="center">
<fieldset>
<legend>Tujuan Pengiriman</legend>
<p>
<label for="full-name" class="label"> Full Name </label>
<input class="input-checkout" required placeholder="Input Name" id="full-name" name="full_name" type="text"/>
</p>
<p>
<label for="alamat" class="label"> Address </label>
<textarea required placeholder="Address" id="address" name="address" type="text"></textarea>
</p>
<p>
<label for="telpon" class="label"> Phone Number </label>
<input class="input-checkout" required placeholder="Phone Number" id="telpon" name="phone_number" type="text"/>
</p>
</fieldset>
</div>
<div align="center">
<fieldset>
<legend>Detail Pesanan</legend>
<?php
$sid = $_SESSION['username'];
$subtotal = 0;
$total = 0;
$query = "SELECT p.product_name, p.product_image, p.product_price, c.id, c.amount
FROM product p INNER JOIN cart c
ON c.product_id = p.product_id
WHERE c.session_id = '$sid'";
$result = mysqli_query($connect, $query);
$row = mysqli_num_rows($result);
if ($row == 0) {
echo "<h1 align='center'>TIDAK ADA PESANAN</h1>";
} else {
while ($data = mysqli_fetch_array($result)) {
$id = $data['id'];
?>
<!-- Product #1 -->
<div class="item">
<div class="image">
<img src="img/<?php echo $data['product_image']; ?>" alt="<?php echo $data['product_name']; ?>">
</div>
<div class="description">
<span><?php echo $data['product_name']; ?></span>
</div>
<div class="quantity">
<span><?php echo $data['amount']; ?></span>
</div>
<?php
$subtotal = $data['product_price']*$data['amount'];
$total = $total + $subtotal;
?>
<div class="subtotal-price">Rp <?php echo number_format($subtotal,2,',','.'); ?></div>
</div>
<?php
}
echo "<div class='total-checkout'>Rp ".number_format($total,2,',','.')."</div>";
}
?>
</fieldset>
</div>
<button type="submit">Check Out</a>
</form>
</div>