Print Templates allow you to create your own templates for printing. Your BookingCentral account already comes with an invoice print template defined. You can add more print templates if needed.
This article will give you a brief introduction to how to write your own Print Template.
How Print Templates work
Print Templates are made of HTML codes, the language that is used to create websites. HTML is extremely powerful and by using HTML code for templates, you can create customized templates for almost anything.
HTML is a special kind of text document that includes markup tags to indicate the beginning and the end of each block. There are many different tags and we’ll just touch on a few in this help article.
Some of the most common tags are header tags <h1></h1>, paragraph tags <p></p> and division <div></div>.
Here is an example
<h1>Invoice</h1>
<p>Invoice from Riverside Rentals</p>
Variables
Variables are codes that will be substituted with values from the order. All variables have the form ${variable name}. For example, the variable for order code is
${order.ordercode}
Here we include ordercode as well as the customer fullname, email and phone:
<h1>Invoice</h1>
<p>Invoice ${order.ordercode} from Riverside Rentals</p>
<div>
${customer.name}<br/>
${customer.email}<br/>
${customer.phone}
</div>
Note the use of the division tag <div></div> and the new line tag <br/>. We use the <div> tag to group the customer name, email and phone together, and then we use the <br/> tag to put each on a separate line.
Loops
In cases where there may be more than one item, you will use a loop to iterate over all the items. This is the case for order lines and payments since there can be more than one of each.
A loop is started with the #foreach keyword and must be terminated with the #end keyword
#foreach($orderline in $orderlines)
... html code here...
#end
Notice the ($orderline in $orderlines). This tells the system that we want to iterate over each orderline, one by one. Inside the loop, we can print the orderline details using the ${orderline} variables:
#foreach($orderline in $orderlines)
<div>
Product: ${orderline.product}, Start At: ${orderline.startat}, End At: ${orderline.endat}
</div>
#end
Full Example
Here is the full example:
<h1>Invoice</h1>
<p>Invoice ${order.ordercode} from Riverside Rentals</p>
<div>
${customer.name}<br/>
${customer.email}<br/>
${customer.phone}
</div>
<h2>Order Details</h2>
#foreach($orderline in $orderlines)
<div>
Product: ${orderline.product}, Start At: ${orderline.startat}, End At: ${orderline.endat}
</div>
#end
<p>The total amount is ${order.totalamount}. You deposit payment is ${order.depositamount}</p>
See related articles on Print Templates:
How to add styles to a print template
How to create a table in a print template
How to use conditional formatting in a print template
Introduction to html:
https://www.simplilearn.com/tutorials/html-tutorial/html-tags