Thank you @VACUUMDOG … this works! With the help of ChatGPT I’m using ‘strip’ filters to make sure extra spaces aren’t added, shown below.
For anyone interested the code I’m using is as follows:
Subject
{% capture invoice_number %}{% for field in fields %}{% if field.label == "Invoice number" %}{{ field.text }}{% endif %}{% endfor %}{% endcapture %} Invoice {{ invoice_number }} from BUSINESS NAME
Body
{% for total in table.totals %}
{% if total.label == 'Total' %}
{% capture invoice_total %}{{ total.text | strip }}{% endcapture %}
{% endif %}
{% endfor %}
{% capture invoice_number %}
{% for field in fields %}
{% if field.label == "Invoice number" %}
{{ field.text | strip }}
{% endif %}
{% endfor %}
{% endcapture %}
{% capture due_date %}
{% for field in fields %}
{% if field.label == "Due date" %}
{{ field.text | strip }}
{% endif %}
{% endfor %}
{% endcapture %}
{% for total in table.totals %}
{% if total.label == 'Balance due' %}
{% capture balance_due %}{{ total.text | strip }}{% endcapture %}
{% endif %}
{% endfor %}
{% capture if_balance_due %}
{% if balance_due == blank %}
{{ invoice_total | strip }}
{% else %}
{{ balance_due | strip }}
{% endif %}
{% endcapture %}
Dear {{ recipient.name | strip }},
Please find attached Invoice {{ invoice_number | strip }} for the amount of {{ invoice_total | strip }}.
The outstanding balance of {{ if_balance_due | strip }} is due for payment by {{ due_date | strip }}.
If you have any questions or require further information, please don’t hesitate to contact me.
BUSINESS EMAIL SIGNATURE
Which will output

