<?php
session_start();
include 'includes/connect.php';

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

$user_id = $_SESSION['user_id'] ?? $_SESSION['distributor_id'] ?? 0;

$data = json_decode(file_get_contents("php://input"), true);

$id = intval($data['id']);

mysqli_query($conn,"DELETE FROM cart WHERE id='$id' AND user_id='$user_id'");

echo json_encode(["success"=>true]);