<?php
session_start();

if (!isset($_SESSION['cart']) || !is_array($_SESSION['cart'])) {
    $_SESSION['cart'] = [];
}

if (isset($_POST['meal_id']) && isset($_POST['quantity'])) {
    $meal_id = intval($_POST['meal_id']);
    $quantity = intval($_POST['quantity']);

    if ($quantity <= 0) {
        unset($_SESSION['cart'][$meal_id]);
    } else {
        $_SESSION['cart'][$meal_id] = $quantity;
    }
    
    echo "تم تحديث السلة";
}
