<?php
require_once '../config.php';

header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    echo json_encode(['success' => false]);
    exit;
}

$equipment_id = isset($_GET['equipment_id']) ? (int)$_GET['equipment_id'] : 0;

if (!$equipment_id) {
    echo json_encode(['success' => false]);
    exit;
}

try {
    $cart_id = $_SESSION['cart_id'];
    $stmt = $pdo->prepare("DELETE FROM cart_items WHERE cart_id = ? AND equipment_id = ?");
    $stmt->execute([$cart_id, $equipment_id]);
    
    echo json_encode(['success' => true]);
} catch(PDOException $e) {
    echo json_encode(['success' => false]);
}
?>