Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JAQA20/LaComanda/llms.txt

Use this file to discover all available pages before exploring further.

The Products API provides full lifecycle management for menu items. Waitstaff can retrieve products filtered by category slug to populate order forms, while administrators can create new items, update prices or icons, and remove products that are no longer offered. All endpoints require an active PHP session; write operations are further restricted to accounts with rol_id = 1 (Admin).

List Products

Available to any authenticated user. Returns only active products (activo = 1) matching the given category slug.
GET /public/api/listarProductos.php Returns the list of active products belonging to the specified category. Passing categoria=mesas always returns an empty array because the mesas category is used solely for table-charge line items and contains no orderable products.

Query Parameters

categoria
string
required
The URL slug of the category to filter by (e.g. cafes, bebidas, comidas). Use categoria=mesas to intentionally receive an empty product list.

Response

{
  "status": "OK",
  "data": [
    {
      "id": 1,
      "nombre": "Espresso",
      "precio": 1800.00,
      "icono": "fa-mug-hot"
    }
  ]
}
status
string
Always "OK" on success.
data
array
Array of product objects matching the requested category.
data[].id
integer
Unique product identifier.
data[].nombre
string
Display name of the product.
data[].precio
number
Unit price in the local currency (decimal).
data[].icono
string
Font Awesome icon class used to represent this product in the UI (e.g. fa-mug-hot).

Example Request

curl -b 'PHPSESSID=...' \
  'http://localhost:8080/public/api/listarProductos.php?categoria=cafes'

Create Product

Requires rol_id = 1 (Admin). Non-admin sessions are rejected before any data is written.
POST /public/api/nuevoProducto.php Creates a new product and associates it with a category. On success the browser is redirected to the admin products view. Validation errors are written to the PHP session so the form page can display them without losing user input.

Request Parameters

categoria_id
integer
required
Database ID of the category this product belongs to.
nombre
string
required
Display name for the product.
precio
number
required
Unit price. Accepts integer or decimal values (e.g. 1800 or 1800.50).
icono
string
Font Awesome icon class. Defaults to fa-mug-hot when omitted.
activo
integer
Checkbox value — 1 to make the product visible to staff, 0 (or omit) to create it as inactive.

Responses

OutcomeRedirect
Successviews/admin/productos.php?created=1
Validation failureBack to form; errors in $_SESSION["nuevo_producto_errors"]
Read $_SESSION["nuevo_producto_errors"] in your form view to surface field-level messages (e.g. missing name, invalid price) without a separate API call.

Example Request

curl -b 'PHPSESSID=...' \
  -X POST \
  -F 'categoria_id=2' \
  -F 'nombre=Cappuccino' \
  -F 'precio=2200' \
  -F 'icono=fa-mug-hot' \
  -F 'activo=1' \
  'http://localhost:8080/public/api/nuevoProducto.php'

Edit Product

Requires rol_id = 1 (Admin).
POST /public/api/editarProducto.php Updates an existing product record. You must supply the product id; all other fields overwrite the stored values, so include every field you wish to keep unchanged.

Request Parameters

id
integer
required
ID of the product to update.
categoria_id
integer
New category assignment for this product.
nombre
string
Updated product name.
precio
number
Updated unit price.
icono
string
Updated Font Awesome icon class.
activo
integer
1 to mark active, 0 to deactivate (hides from order forms).

Responses

OutcomeRedirect
Successviews/admin/productos.php?updated=1

Example Request

curl -b 'PHPSESSID=...' \
  -X POST \
  -F 'id=1' \
  -F 'categoria_id=2' \
  -F 'nombre=Espresso Doble' \
  -F 'precio=2500' \
  -F 'icono=fa-mug-hot' \
  -F 'activo=1' \
  'http://localhost:8080/public/api/editarProducto.php'

Delete Product

Requires rol_id = 1 (Admin). Products referenced by existing order line items cannot be deleted due to foreign-key constraints.
POST /public/api/eliminarProducto.php Permanently removes a product from the catalog. If the product is referenced by any order detail record, the database foreign-key constraint prevents deletion and the endpoint redirects with an error message.

Request Parameters

id
integer
required
ID of the product to delete.

Responses

OutcomeRedirect
Successviews/admin/productos.php?deleted=1
FK constraint or other errorviews/admin/productos.php?error=<message>

Example Request

curl -b 'PHPSESSID=...' \
  -X POST \
  -F 'id=1' \
  'http://localhost:8080/public/api/eliminarProducto.php'

Build docs developers (and LLMs) love