<?php
require_once('includes/load.php');
$orderId = isset($_GET['order_id']) ? (string)$_GET['order_id'] : "";
$data = [];

// Fungsi untuk mengambil data item
if ($orderId > 0) {
    $stmt = $db->prepare(
        "SELECT order_item_id, item_name, model_sku, model_quantity_purchased, CASE WHEN model_discounted_price = 0 THEN model_original_price ELSE model_discounted_price END AS final_price, image_url FROM order_detail where order_id = ? AND deleted_at is null"
    );
    $stmt->bind_param("i", $orderId);
    $stmt->execute();
    $result = $stmt->get_result();
    $data = $result->fetch_all(MYSQLI_ASSOC);
}

// Mengembalikan data dalam format JSON
header('Content-Type: application/json');
echo json_encode($data);
