<?php
require_once __DIR__ . '/../app/auth.php';
require_once __DIR__ . '/../app/orders.php';

$user = sparrow_require_backyard_login();

$order_id = (int) ($_POST['order_id'] ?? 0);
if ($order_id <= 0) {
    http_response_code(400);
    echo json_encode(['error' => 'Invalid order ID']);
    exit;
}

try {
    sparrow_delete_order($order_id); // You’ll add this function
    echo json_encode(['success' => true]);
} catch (Throwable $e) {
    http_response_code(500);
    echo json_encode(['error' => $e->getMessage()]);
}