Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 3957e972 authored by 65160381's avatar 65160381
Browse files

Update 2 files

- /controllers/cartController.js
- /controllers/productController.js
parent af641919
Branches
No related tags found
No related merge requests found
Pipeline #655 passed with warnings
......@@ -82,7 +82,7 @@ exports.checkout = async (req, res) => {
// เพิ่มรายการสินค้าลงใน Order_Items
const orderItems = cart.map(item => [orderId, item.product_id, item.quantity, item.price]);
await pool.query('INSERT INTO order_items (order_id, book_id, quantity, price) VALUES ?', [orderItems]);
await pool.query('INSERT INTO order_items (order_id, phone_id, quantity, price) VALUES ?', [orderItems]);
// ล้างตะกร้าหลังจาก Checkout สำเร็จ
req.session.cart = [];
......
......@@ -114,7 +114,7 @@ exports.orderHistory = async (req, res) => {
const [items] = await pool.query(
`SELECT oi.*, p.product_name, p.image
FROM order_items oi
JOIN products p ON oi.book_id = p.product_id
JOIN products p ON oi.phone_id = p.product_id
WHERE oi.order_id = ?`,
[order.order_id]
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment