-
Notifications
You must be signed in to change notification settings - Fork 2
/
order_details.php
113 lines (104 loc) · 5.07 KB
/
order_details.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
<?php
require('services/check_user_login.php');
include("services/connect.php");
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<?php include('user/components/head.php') ?>
</head>
<body>
<?php
include("services/connect.php");
?>
<!-- header start -->
<?php include('user/components/header.php') ?>
<!-- header end -->
<!-- body start -->
<body>
<?php
//lấy id của bản ghi cần xem
$id = $_GET['id'];
$sql = "SELECT * FROM order_product WHERE id_order = '$id'";
$rs = mysqli_query($connect, $sql);
?>
<div class="cart-main-area pt-95 pb-100">
<br><br><br><br><br><br><br>
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-6">
<h1 class="cart-heading">Chi tiết hóa đơn</h1>
<form action="#">
<div class="table-content table-responsive">
<?php
//lấy giỏ hàng
if (isset($_SESSION['user'])) {
?>
<table class="table table-hover">
<thead>
<tr>
<th>STT</th>
<th>Tên sản phẩm</th>
<th>Hình ảnh</th>
<th>Số lượng</th>
<th>Đơn giá</th>
<th>Thành tiền</th>
</thead>
<tbody>
<?php
$count = 0;
$total = 0;
while ($row = mysqli_fetch_assoc($rs)) {
$product_id = $row['id_product'];
$sql2 = "SELECT * FROM products WHERE id= '$product_id'";
$rs2 = mysqli_query($connect, $sql2);
$row2 = mysqli_fetch_assoc($rs2);
$count++;
?>
<tr>
<td><?= $count ?></td>
<td><?= $row2['name'] ?></td>
<td><img style="width:100px" src="public/images/<?= $row2['image'] ?>" alt=""></td>
<td><?= $row['quantity'] ?></td>
<th><?= number_format($row2['price'] * (100 - $row2['discount']) / 100) ?></th>
<td><?= number_format($row['quantity'] * $row2['price'] * (100 - $row2['discount']) / 100) ?></td>
<?php
$total += ($row['quantity'] * $row2['price'] * (100 - $row2['discount']) / 100);
?>
</tr>
<?php
// close while()
}
?>
<tr>
<td colspan="5"><strong>Tổng tiền</strong></td>
<td><b id="tongTien"><?= number_format($total) ?></b></td>
</tr>
</tbody>
</table>
<?php
} else {
echo 'Đăng nhập để xem lại lịch sử mua hàng';
}
?>
</div>
<div class="row">
<div class="col-md-5 ml-auto">
<div class="cart-page-total">
<a href="index.php">Trở về trang chủ</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
<!-- footer start -->
<?php
include('user/components/footer.php');
?>
<!-- all js here -->
<?php include('user/components/link_footer.php') ?>
</html>