View source | Discuss this page | Page history | Printable version   

POS - Script Happy hour functionality

Code snippet

Name: POS - Happy Hour functionality
Version: POS/2.20 & 2.30 Beta
Author: Mikel Irurita

This code snippet is intented to implement a simple Happy hour functionality.

This code has been copied from this forum thread.

The script allow user to specify the time range (start - end hour) and the quantity of the discount to be applied during the Happy hour.

  1. Login as Administrator and go to Maintenance-->Resources and select Ticket.Buttons resource.
  2. Add a new line:
    <event key="ticket.addline" code="event.happyhour"/>
  3. Create new resource event.happyhour with this content:
 import java.util.Calendar;
 Calendar cal = Calendar.getInstance();
 int hour = cal.get(Calendar.HOUR_OF_DAY);
 discountrate = 0.2;
 //Happy hour range
 start = 12;
 end = 13; 
 if (hour>=start && hour<end) {
   p = line.getPrice();
   line.setPrice(p - (p*discountrate));

You can modify the discount rate and also the period (start and end).

4. Save changes and restart the application.

The discount will be applied to new added lines if the current time is between selected range.

Retrieved from ""

This page has been accessed 10,088 times. This page was last modified on 27 April 2009, at 11:26. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.