Using Manager v 17.10.26
Either I’m missing some key information or the varialbe “fields” is messed up between the theme and the actual invoice.
If there’s another way to access invoice number and date OTHER than “fields”, please let me know, otherwise read on.
Loosely similar to @tomas question I wanted to access invoice date and number variables individually so that I could place them different areas of the invoice.
First attempt (simplified):
<div>Invoice # {{ fields[0].text }}</div> <div>Date: {{ fields[1].text }}</div>
This looks perfect in the theme preview, however the fields’ indeces CHANGE in the actual invoices to which the theme is applied.
Invoice # [shows invoice date] Date: [ shows invoice due date]
To work around the percieved defect, I used an “if” for each:
e.g.
<div>Invoice #
{% for field in fields %}
{% if field.label == 'Reference' %}
{{ field.text }}
{% endif %}
{% endfor %}</div>
Again, looked GREAT in the theme preview, but doesn’t work in the actual invoices (shows blank).
After a little debugging, I found the LABELs are different between the actual invoice and the theme, so I resolved it with:
<div>Invoice #
{% for field in fields %}
{% if field.label == 'Invoice number' %}
{{ field.text }}
{% endif %}
{% endfor %}</div>
- if the invoice reference, date and due date are available in other variables, please let me know
- if not, would it be feasible to make them more accessible like “recipient” and “business”?
e.g.
invoice.reference
invoice.date
invoice.dueDate
…or even an associative array (hash)?
fields['reference']
filesd['date']
fields['dueDate']
- Lastly, could the ‘text’ fields be at least made the same between invoice and theme?
Thanks for reading this far.
Ron