getConnection(); try { $orderStmt = $db->prepare(" SELECT o.*, u.email, u.full_name FROM orders o LEFT JOIN users u ON o.user_id = u.user_id WHERE o.order_id = ? "); $orderStmt->execute([$orderId]); $order = $orderStmt->fetch(); if (!$order) { die('Заказ не найден'); } $itemsStmt = $db->prepare(" SELECT * FROM order_items WHERE order_id = ? "); $itemsStmt->execute([$orderId]); $order_items = $itemsStmt->fetchAll(); } catch (PDOException $e) { die('Ошибка базы данных: ' . $e->getMessage()); } ?>
Дата: = date('d.m.Y H:i', strtotime($order['created_at'])) ?>
Статус: = $order['status'] ?>
ФИО: = htmlspecialchars($order['customer_name']) ?>
Email: = htmlspecialchars($order['customer_email']) ?>
Телефон: = htmlspecialchars($order['customer_phone']) ?>
Адрес: = nl2br(htmlspecialchars($order['delivery_address'])) ?>
Способ доставки: = $order['delivery_method'] == 'courier' ? 'Курьер' : 'Самовывоз' ?>
Способ оплаты: = $order['payment_method'] == 'card' ? 'Карта' : 'Наличные' ?>
| № | Товар | Кол-во | Цена | Сумма |
|---|---|---|---|---|
| = $counter++ ?> | = htmlspecialchars($item['product_name']) ?> | = $item['quantity'] ?> | = number_format($item['unit_price'], 0, '', ' ') ?> ₽ | = number_format($item['total_price'], 0, '', ' ') ?> ₽ |
| Сумма товаров: | = number_format($order['total_amount'], 0, '', ' ') ?> ₽ | |||
| Скидка: | -= number_format($order['discount_amount'], 0, '', ' ') ?> ₽ | |||
| Доставка: | = number_format($order['delivery_cost'], 0, '', ' ') ?> ₽ | |||
| Итого к оплате: | = number_format($order['final_amount'], 0, '', ' ') ?> ₽ | |||
= nl2br(htmlspecialchars($order['notes'])) ?>