Skip to main content

14.7 Custom Functions in PDF

It is possible to define custom functions for data processing within the PDF Maker. To add a custom function, place the PHP file with the function code inside the modules/PDFMaker/function folder; the file will be included automatically.
The its4you.php function is inside the folder. Do not modify this file; any changes will be overwritten the next time you update the application.
To add a custom function to your template, go to the More information tab and choose the desired function and then click Insert in the template:

14.7 [1].PNG

Guide example: if-else:

If you choose the if-else function, the following text will be added to the template: [CUSTOMFUNCTION|its4you_if|param1|comparator|param2|return1|return2|- CUSTOMFUNCTION]

Replace:
param1 – control range
comparator – benchmark, possible values: = , != (different), >, < param2 – benchmark
return1 – value to be displayed if the condition is verified
return2 – value to be displayed if the condition is NOT verified

Let's see how to configure the function so that the final discount in the Quote will be printed only if not invalid:

[CUSTOMFUNCTION|its4you_if|$TOTALDISCOUNT$|!=|0,00|Discount$TOTALDISCOUNT$ €||CUSTOMFUNCTION]