View Categories

Printing a coupon along with the receipt

1 min read

Coupons can be printed automatically based on the conditions set.

Maintenance > Resources
The below script can be used to print a discount coupon if the total bill amount is more than 3000. The coupon also show an expiry date for the coupon. Use this script in Printer.Ticket. Create an image resource, Printer.Ticket.SpecialOffer.Logo for printing in coupon.

<!-- TICKET COUPON START -->
        #if ($ticket.getTotal() > 3000)
         <line>
         </line>
         <line>
           <text>------------------------------------------------</text>
         </line>
 <line>
 <image>Printer.Ticket.SpecialOffer.Logo</image>
        </line>
 <line>
           <text align ="center" length="48" bold="true" underline="true">DISCOUNT COUPON</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="48" bold="true">Expires:$d/$m/$y</text>
         </line>
         <line>
           <text align ="center" length="48">This coupon entitles you to receive </text>
         </line>
 <line>
         </line>
 <line size="3">
           <text align ="center" length="12" >5%</text>
         </line>
        <line size="3">
           <text align ="center" length="12" >DISCOUNT</text>
         </line>
         <line>
         <text align ="center" length="48">when you purchase next time from us.</text>
         </line>
         #if (${ticket.ticketType} == 0)
         <line>
           <text align="center" length="48">Receipt:${ticket.printId()}</text>
         </line>
         #end
         <line>
           <text>------------------------------------------------</text>
         </line>
        #end
<!-- TICKET COUPON END -->

Save & restart

0 Comments

Leave a Reply

Arrow-up