POS - Ticket Coupon
Code snippetName: POS - POS - Ticket Coupon
|
This code was created using mySQL in Windows.
This script will allow you to add a coupon to a ticket. It will print when the ticket total is above the set amount (e.g 14.99). This example is has expiry set to 14 days in the future ($d = $d + 14). See this forum post.
1) Add code to the Printer.Ticket Resource
Add the following code to the Printer.Ticket resource on the line before </ticket> for coupon to print at bottom of receipt:
#if ($ticket.getTotal() > 14.99) <line> </line> <line> <text>------------------------------------------</text> </line> <line> <text align ="center" length="42" bold="true">Free Product Offer</text> </line> #set($y = $ticket.getDate().getYear() + 1900) #set($m = $ticket.getDate().getMonth() + 1) #set($d = $ticket.getDate().getDate()) #set($d = $d + 14) #if ((($m ==4) || ($m ==6) || ($m ==9) || ($m ==11)) && ($d > 30)) #set($m = $m + 1) #set($d = $d - 30) #elseif (($m ==2) && ($d > 28)) #set($m = $m + 1) #set($d = $d - 28) #elseif ($d > 31) #set($m = $m + 1) #set($d = $d - 31) #end #if($m > 12) #set($m = 1) #set($y = $y + 1) #end <line> <text align ="center" length="42" bold="true">Expires:$d/$m/$y</text> </line> <line> <text align ="center" length="42">This receipt entitles you to receive one</text> </line> <line> <text align ="center" length="42">free small product when you purchase any</text> </line> <line> <text align ="center" length="42">other product from us.</text> </line> #if (${ticket.ticketType} == 0) <line> <text align="center" length="42">Receipt:${ticket.printId()}</text> </line> #end <line> <text>------------------------------------------</text> </line> #end
That should be it. You can obviously change anything you wish to suite your setup.
Let me know if something is not working or something can be bone better.
Finally, remind that the methods getYear, getMonth and getDate are deprecated and calculation may be out by one day in a leap year.
Good Luck,
Ronny G