<?php
session_start();

if (isset($_SESSION['purchaseCart']) && !empty($_SESSION['purchaseCart'])) {
    $cartItems = $_SESSION['purchaseCart'];
    $output = '';

    foreach ($cartItems as $index => $item) {
        $output .= '<tr>';
        $output .= '<td>' . ($index + 1) . '</td>';
        $output .= '<td>' . $item['name'] . '</td>';
        $output .= '<td>' . $item['category'] . '</td>';
        $output .= '<td>' . $item['quantity'] . '</td>';
        $output .= '<td>' . $item['unit'] . '</td>';
        $output .= '<td>';
        $output .= '<button type="button" class="btn btn-danger btn-sm remove-from-cart" data-index="' . $index . '">Remove</button>';
        $output .= '</td>';
        $output .= '</tr>';
    }

    echo $output;
} else {
    echo '<tr><td colspan="5">No items in purchaseCart</td></tr>';
}
?>
