The Promotions module (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProyectoFerretek/FerreMarket/llms.txt
Use this file to discover all available pages before exploring further.
/promociones) lets you create and manage discount codes for FerreMarket customers. Each promotion is identified by a human-readable code, carries date-range validity, supports both percentage and fixed-amount discount types, and can be targeted to specific products, categories, or customer types. The module also includes a per-promotion analytics panel showing conversion rate, revenue generated, peak-usage hours, and top-selling products under the promotion.
Summary Statistics
Three KPI cards appear at the top of the Promotions page and update whenever thepromociones array changes:
| Card | Metric |
|---|---|
| Promociones activas | Count of promotions where estado === 'activo' |
| Total de usos | Sum of usosActuales across all promotions |
| Ingresos generados | Sum of ingresoGenerado across all promotions, formatted as CLP |
Promotion Fields
ThePromocion TypeScript interface from src/types/index.ts defines all available fields:
Core fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier assigned by Supabase |
codigo | string | The promo code entered at checkout (e.g. DESCUENTO20) |
nombre | string | Human-readable name displayed in the admin UI |
tipo | string | Discount calculation method — 'porcentaje' or 'monto_fijo' |
valor | number | Discount magnitude — percentage points or CLP amount depending on tipo |
valorMaximo | number (optional) | Maximum CLP discount cap for percentage promotions |
montoMinimo | number | Minimum purchase amount (CLP) required to apply the promotion |
fechaInicio | string | ISO 8601 start datetime in America/Santiago timezone |
fechaFin | string | ISO 8601 expiry datetime in America/Santiago timezone |
estado | string | 'activo' / 'pausado' / 'expirado' / 'borrador' |
combinable | boolean | Whether the code can be stacked with other active promotions |
descripcion | string (optional) | Longer description shown in communications |
fechaCreacion | string | ISO 8601 timestamp when the promotion was created |
creadoPor | string | Username or 'Admin' |
Usage limits
| Field | Type | Description |
|---|---|---|
limiteTotalUsos | number (optional) | Maximum times the code can be redeemed across all customers |
limiteUsosPorCliente | number (optional) | Maximum redemptions per individual customer |
usosActuales | number | Running count of times the code has been used |
Targeting fields
| Field | Type | Description |
|---|---|---|
aplicaA | string | Scope: 'toda_tienda', 'productos', or 'categorias' |
productosIncluidos | string[] | Product IDs the discount applies to (when aplicaA === 'productos') |
productosExcluidos | string[] | Product IDs explicitly excluded from the discount |
categoriasIncluidas | string[] | Category IDs the discount applies to (when aplicaA === 'categorias') |
categoriasExcluidas | string[] | Category IDs explicitly excluded |
tipoCliente | string | Target audience: 'todos', 'nuevo', 'recurrente', etc. |
Analytics fields
| Field | Type | Description |
|---|---|---|
ingresoGenerado | number | Total CLP revenue attributed to this promotion |
valorPromedioCompra | number | Mean order value (CLP) for transactions using this code |
tasaConversion | number | Conversion rate as a percentage |
horariosUso | string[] | Usage data bucketed by hour band. The analytics modal iterates this with Object.entries(), treating it as a Record<string, number> keyed by bands such as '00-06', '06-12', '12-18', '18-24'. |
productosVendidos | string[] | Products sold under this promotion with quantity and revenue data |
Creating a Promotion
Open the modal
Click the orange Nueva Promoción button in the top-right header.
PromocionModal opens with all fields empty.Set the code and name
Enter a unique
codigo (e.g. FERREVERANO25) and a descriptive nombre. The code is case-sensitive and must be unique in the promociones table.Choose type and value
Select Porcentaje or Monto Fijo. Enter the discount
valor. For percentage discounts, optionally set a valorMaximo cap to prevent excessively large discounts on high-value orders.Set date range and minimum purchase
Enter
fechaInicio and fechaFin using the date-time pickers. Optionally set montoMinimo to require a qualifying cart value.Configure usage limits
Set
limiteTotalUsos (total redemptions across all customers) and limiteUsosPorCliente (per-customer cap). Leave at 0 for unlimited.Set targeting rules
Choose the
aplicaA scope and optionally populate include/exclude lists for products and categories.Promotion Types
Percentage (porcentaje)
Discounts the cart by valor percent of the qualifying subtotal:
valor: 20 promotion with valorMaximo: 50000 gives 20% off up to a maximum of CLP 50,000, regardless of cart size.
Fixed Amount (monto_fijo)
Deducts a flat CLP amount from the qualifying subtotal:
valor: 15000 welcome promotion deducts CLP 15,000 from the cart when montoMinimo is met.
Targeting Rules
aplicaA value | Behaviour |
|---|---|
toda_tienda | Applies to all products in the cart |
productos | Applies only to products whose IDs appear in productosIncluidos |
categorias | Applies only to products belonging to categories in categoriasIncluidas |
productosExcluidos or categoriasExcluidas are always exempt, even when the scope is toda_tienda. The tipoCliente field further restricts which customers can redeem the code ('todos' means no restriction).
Usage Limits
Each promotion tracks its redemption count inusosActuales. The progress bar on each promotion card visualises this as (usosActuales / limiteTotalUsos) × 100. When a promotion reaches its limit, it transitions to expirado status automatically.
limiteTotalUsos— hard cap across the entire store. Useful for scarcity-based campaigns (“first 1,000 uses”).limiteUsosPorCliente— prevents the same customer from stacking repeated redemptions. Set to1for single-use codes like new-customer welcome discounts.
Analytics
Click the Análisis button on any promotion card to openModalAnalisis. The panel shows:
Revenue metrics
Total usos, ingresos generados (CLP), and valor promedio de compra — shown as three coloured KPI boxes.
Peak-hour chart
Horizontal bar chart of
horariosUso bucketed by 6-hour bands (00-06, 06-12, 12-18, 18-24) showing relative activity volume.Top products
Ranked list of
productosVendidos showing product name, units sold, and revenue, with a proportional progress bar.Detailed info
Full metadata grid: creation date, author, validity period,
limiteUsosPorCliente, combinable flag, and tipoCliente scope.