prepare('SELECT * FROM orders WHERE id = :order_id AND client_id = :client_id'); $stmt->execute([':order_id' => $order_id, ':client_id' => $client_id]); $order = $stmt->fetch(); if (!$order) { $error_message = t('order_not_found_or_unauthorized'); } else { $stmt = $pdo->prepare( 'SELECT oi.*, p.name as product_name FROM order_items oi JOIN products p ON oi.product_id = p.id WHERE oi.order_id = ?' ); $stmt->execute([$order_id]); $order_items = $stmt->fetchAll(); if (!empty($order_items)) { $product_ids = array_map(fn($item) => $item['product_id'], $order_items); $placeholders = implode(',', array_fill(0, count($product_ids), '?')); $image_stmt = $pdo->prepare( "SELECT product_id, file_path, is_primary, id FROM product_images WHERE product_id IN ($placeholders) ORDER BY product_id, is_primary DESC, id ASC" ); $image_stmt->execute($product_ids); $images_data = $image_stmt->fetchAll(); $product_images_temp = []; foreach ($images_data as $image) { if (!isset($product_images_temp[$image['product_id']])) { $product_images_temp[$image['product_id']] = 'uploads/products/' . $image['product_id'] . '/' . basename($image['file_path']); } } $product_images = $product_images_temp; } } } catch (PDOException $e) { $error_message = t('db_error_generic'); error_log($e->getMessage()); } } $page_title = $order ? str_replace('{order_id}', $order['id'], t('order_details_title')) : t('order_details_fallback_title'); require_once __DIR__ . '/includes/html_head.php'; require_once __DIR__ . '/includes/header.php'; require_once __DIR__ . '/includes/currency.php'; ?>

:

:

:

:

:

<?= htmlspecialchars($item['product_name']) ?>