Overview
The Products API provides endpoints for creating, updating, searching, and deleting product records. All endpoints require authentication via session.Create Product
Product code (up to 20 characters, must be unique)
Product name (up to 255 characters)
Product price (sale price)
Product status:
1 for active, 0 for inactiveReturns HTML alert with success message: “Producto ha sido ingresado satisfactoriamente.”
Returns HTML alert with error message if validation fails
Update Product
Product ID to update
Updated product code
Updated product name
Updated product price
Updated status:
1 for active, 0 for inactiveReturns HTML alert with message: “Producto ha sido actualizado satisfactoriamente.”
Returns HTML alert with error message if validation fails
Search Products
Must be set to
"ajax" to trigger searchSearch term to filter products by code or name. Leave empty to return all products.
Page number for pagination (default: 1, 10 results per page)
Returns HTML table with product data including:
id_producto- Product IDcodigo_producto- Product codenombre_producto- Product namestatus_producto- Status (1 = Active, 0 = Inactive)precio_producto- Product pricedate_added- Date added (formatted as d/m/Y)
Delete Product
Product ID to delete
Returns success alert if product is deleted successfully
Returns error alert if:
- Product has associated invoice line items (foreign key constraint)
- Database error occurs
Products cannot be deleted if they are referenced in any invoice line items (detalle_factura table).
Search Products for Invoice
Must be set to
"ajax" to trigger searchSearch term to filter products by code or name
Page number for pagination (default: 1, 5 results per page)
Returns HTML table with simplified product data for invoice creation:
- Product code
- Product name
- Quantity input field (default: 1)
- Price input field (editable)
- Add button to add product to invoice
This endpoint is specifically designed for use in the invoice creation interface. It returns 5 products per page (instead of 10) and includes interactive form elements.
