Single template for standard/paid/overdue

How about use conditionals to merge this three templates in only one file?

if the invoice is overdue a simple “if” will add overdue class to the html/pdf
if the invoice is paid another “if” will add payment text to the html/pdf

In this way changing one file will reflect changes in all the templates without have to mirror changes on three files.

This is already possible with a custom template: just select the same template for “Default PDF Template”, “Paid PDF Template” and “Overdue PDF Template” in the settings and add the desired conditions in the template.

I have just compared the original files and the only differences are some colors. Those could be assigned like (not tested):
echo '<td class="' . ($invoice->is_overdue ? 'text-red' : '') . '">';

I agree, it would make thinks easier if the 3 original sample-templates would be merged to a single file.

1 Like