I can’t get this to work, looks like TemplateService.php is not used, or is being cached somehow. I can even remove the file without any error raised. I added the contacts lastname:
$variables = [
'$footer' => $account->getEmailFooter(),
'$emailSignature' => $account->getEmailFooter(),
'$client' => $client->getDisplayName(),
'$idNumber' => $client->id_number,
'$vatNumber' => $client->vat_number,
'$account' => $account->getDisplayName(),
'$dueDate' => $account->formatDate($invoice->getOriginal('partial_due_date') ?: $invoice->getOriginal('due_date')),
'$invoiceDate' => $account->formatDate($invoice->getOriginal('invoice_date')),
'$contact' => $contact->getDisplayName(),
'$firstName' => $contact->first_name,
'$lastName' => $contact->last_name,
'$amount' => $account->formatMoney($amount, $client),
'$total' => $invoice->present()->amount,
'$balance' => $invoice->present()->balance,
'$invoice' => $invoice->invoice_number,
'$quote' => $invoice->invoice_number,
'$number' => $invoice->invoice_number,
'$partial' => $invoice->present()->partial,
'$poNumber' => $invoice->po_number,
'$terms' => $invoice->terms,
'$notes' => $invoice->public_notes,
'$link' => $invitation->getLink(),
'$password' => $passwordHTML,
'$viewLink' => $invitation->getLink().'$password',
'$viewButton' => Form::emailViewButton($invitation->getLink(), $entityType).'$password',
'$paymentLink' => $invitation->getLink('payment').'$password',
'$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password',
'$approveLink' => $invitation->getLink('approve').'$password',
'$approveButton' => Form::emailPaymentButton($invitation->getLink('approve'), 'approve').'$password',
'$customClient1' => $client->custom_value1,
'$customClient2' => $client->custom_value2,
'$customContact1' => $contact->custom_value1,
'$customContact2' => $contact->custom_value2,
'$customInvoice1' => $invoice->custom_text_value1,
'$customInvoice2' => $invoice->custom_text_value2,
'$documents' => $documentsHTML,
'$autoBill' => empty($data['autobill']) ? '' : $data['autobill'],
'$portalLink' => $invitation->contact->link,
'$portalButton' => Form::emailViewButton($invitation->contact->link, 'portal'),
];
But nothing happens, the variable is not filled in the template. Any hints?