Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prjcloud_65160270
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160270
prjcloud_65160270
Commits
a5dd9c34
Commit
a5dd9c34
authored
3 months ago
by
65160270
Browse files
Options
Downloads
Patches
Plain Diff
update-address
parent
b6083c10
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
shop-routes/order.js
+8
-7
8 additions, 7 deletions
shop-routes/order.js
views/checkout.ejs
+42
-10
42 additions, 10 deletions
views/checkout.ejs
with
50 additions
and
17 deletions
shop-routes/order.js
+
8
−
7
View file @
a5dd9c34
...
...
@@ -45,9 +45,11 @@ router.get('/history', isAuthenticated, async (req, res) => {
// ดูรายละเอียดออเดอร์ (เฉพาะผู้ที่ Login)
router
.
get
(
'
/detail/:orderId
'
,
isAuthenticated
,
async
(
req
,
res
)
=>
{
try
{
const
sessionId
=
req
.
session
.
id
;
const
[
orders
]
=
await
pool
.
query
(
'
SELECT * FROM orders WHERE id = ? AND session_id = ?
'
,
[
req
.
params
.
orderId
,
req
.
session
.
i
d
]
`
SELECT * FROM orders WHERE id = ? AND session_id = ?
`
,
[
req
.
params
.
orderId
,
session
I
d
]
);
if
(
orders
.
length
===
0
)
{
...
...
@@ -57,8 +59,7 @@ router.get('/detail/:orderId', isAuthenticated, async (req, res) => {
const
order
=
orders
[
0
];
const
[
items
]
=
await
pool
.
query
(
`SELECT
order_items.*, products.name, products.image_url
`SELECT order_items.*, products.name, products.image_url
FROM order_items
JOIN products ON order_items.product_id = products.id
WHERE order_items.order_id = ?`
,
...
...
This diff is collapsed.
Click to expand it.
views/checkout.ejs
+
42
−
10
View file @
a5dd9c34
...
...
@@ -8,6 +8,7 @@
<% } else { %>
<div class="order-summary">
<h3>Order Summary</h3>
<% if (cartItems.length > 0) { %>
<% cartItems.forEach(item => { %>
<div class="order-item">
<span><%= item.name %> x <%= item.quantity %></span>
...
...
@@ -18,6 +19,9 @@
<strong>Total:</strong>
<strong>฿<%= total.toLocaleString() %></strong>
</div>
<% } else { %>
<p>Your cart is empty.</p>
<% } %>
</div>
<form action="/order/create" method="POST" class="checkout-form">
...
...
@@ -27,6 +31,34 @@
</div>
<button type="submit" style="margin: 0; padding: 0.5rem 1rem;">Place Order</button>
</form>
<h3>Your Orders</h3>
<% if (orders.length > 0) { %>
<table border="1">
<thead>
<tr>
<th>Order ID</th>
<th>Total Amount</th>
<th>Status</th>
<th>Shipping Address</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<% orders.forEach(order => { %>
<tr>
<td><%= order.id %></td>
<td>฿<%= order.total_amount.toLocaleString() %></td>
<td><%= order.status %></td>
<td><%= order.shipping_address %></td>
<td><%= order.created_at %></td>
</tr>
<% }) %>
</tbody>
</table>
<% } else { %>
<p>No orders found.</p>
<% } %>
<% } %>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment