後台訂單功能的內容其實都是前面做過的功能的組合,因此可以把前台訂單的頁面複製過來修改就可以了,加快解題速度。
在訂單編號的位置加上一個連結,導引到訂單詳細資料的頁面。
1
2
3
4
5
6<td class="pp">
<!--在連結上加上訂單id,用來導向訂單詳細資料頁面-->
<a href="?do=order_detail&id=<?=$row['id'];?>">
<?=$row['no'];?>
</a>
</td>複製
./front/checkout.php
的內容到./back/order_detail.php
在
./back/order_detail.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
$row=$Order->find($_GET['id']);
<h2 class="ct">
訂單編號
<span style='color:red'><?=$row['no'];?></span>
的詳細資料
</h2>
<table class="all">
<tr>
<td class="tt ct">帳號</td>
<td class="pp"><?=$row['acc'];?></td>
</tr>
<tr>
<td class="tt ct">姓名</td>
<td class="pp"><?=$row['name'];?></td>
</tr>
<tr>
<td class="tt ct">電話</td>
<td class="pp"><?=$row['tel'];?></td>
</tr>
<tr>
<td class="tt ct">住址</td>
<td class="pp"><?=$row['addr'];?></td>
</tr>
<tr>
<td class="tt ct">電子信箱</td>
<td class="pp"><?=$row['email'];?></td>
</tr>
</table>
<table class="all">
<tr class="tt ct">
<td>商品名稱</td>
<td>編號</td>
<td>數量</td>
<td>單價</td>
<td>小計</td>
</tr>
<?php
//把訂單資料中的商品資料還原成陣列
$cart=unserialize($row['cart']);
foreach($cart as $id => $qt){
$item=$Goods->find($id);
<tr class="pp ct">
<td><?=$item['name'];?></td>
<td><?=$item['no'];?></td>
<td><?=$qt;?></td>
<td><?=$item['price'];?></td>
<td><?=$item['price']*$qt;?></td>
</tr>
<?php } ?>
</table>
<!--總價在儲存訂單時已經紀錄在資料中了,
因此直接取出總價即可,不需要再計算一次-->
<div class="all tt ct">總價:<?=$row['total'];?></div>
<div class="ct">
<button onclick="location.href='?do=order'">返回</button>
</div>
最後檢查
後台還有一個 最新消息管理 尚未製作,由於題目中沒有提到這項功能,因此可以考慮刪除這個檔案,或是簡單標示此功能不需製作
./back/news.php1
2<h1 class="ct">最新消息管理</h1>
<h2 class="ct">依題意本功能不需製作</h2>本題組容易錯的地方在後台商品管理及前台購物車的地方,如果有時間檢查,一定要把題目要求的功能流程走過一次,確認不會有功能出不來或是有錯誤訊息跑出來。