Discount Code Engine

Discount types, validation rules, usage limits, and promotional code strategies.

6 min readUpdated 2025-01-12

The discount engine supports percentage discounts, flat amounts, and free tickets with configurable usage limits and expiration rules.

Discount Types

Percentage Off

Type: percent
Value: 1-100
Calculation: ticket_price × (1 - value/100)
Example: 20% off $100 = $80

Fixed Amount Off

Type: fixed
Value: Amount in cents
Calculation: ticket_price - value
Example: $10 off $100 = $90

Free Ticket

Type: percent
Value: 100
Result: $0 ticket (bypass payment)

Buy X Get Y

Type: bogo
Configuration: buy_quantity, free_quantity
Example: Buy 2, Get 1 Free

Discount Code Schema

json
{
  "code": "EARLYBIRD20",
  "type": "percent",
  "value": 20,
  "currency": "usd",           // For fixed discounts
  
  "applies_to": "all",          // all | specific_tickets
  "ticket_ids": [],             // If specific_tickets
  
  "usage_limit": 100,           // Total uses allowed
  "usage_count": 45,            // Current uses
  "per_customer_limit": 1,      // Uses per email
  
  "valid_from": "2025-01-01T00:00:00Z",
  "valid_until": "2025-02-01T00:00:00Z",
  
  "minimum_order": 5000,        // $50 minimum (cents)
  "minimum_quantity": 2,        // Min tickets to apply
  
  "active": true
}

Discount code generator and tester

Interactive component coming soon

Validation Rules

Validation Order 1. Code exists and is active 2. Current time within valid_from/valid_until 3. Usage count < usage_limit 4. Customer hasn't exceeded per_customer_limit 5. Order meets minimum_order amount 6. Order meets minimum_quantity 7. Applicable ticket types in cart

Error Responses • INVALID_CODE: Code doesn't exist • EXPIRED: Past valid_until date • LIMIT_REACHED: Usage limit hit • ALREADY_USED: Customer limit hit • MINIMUM_NOT_MET: Order too small

Code Generation Strategies

Best practices for discount codes:

  • Use descriptive codes: YOGA25 not PROMO1
  • Keep codes short (8 chars max for mobile typing)
  • Set expiration dates to create urgency
  • Limit per-customer usage to prevent abuse
  • Track performance via Analytics → Discount Report
  • Use unique codes for influencer tracking
Generate bulk unique codes for affiliates using the API. Each affiliate gets a trackable code: TEACHER_SARAH, TEACHER_JOHN, etc.

Ready to get started?

Create your first event on BrightStar — it's free.