I have been giving this a good go, but I’m obviously missing something with liquid and manager’s custom fields integration. I’m not getting any result so any help would be appreciated.
My suppliers have 2 particular custom fields (BPay Code
, BPay Reference
).
My invoices have one custom field (test
)
I am trying to print all the custom fields for the supplier
on the invoice. I know from other posts they are called recipient
now, at least in as far as the theme is concerned, and accrording also to the line immediately above where I’m trying to inject my code.
This is what I have:
<table style="margin-bottom: 20px"><tr>
<td>
<div style="font-weight: bold">{{ recipient.name }}</div>
<div>{{ recipient.address | newline_to_br }}</div>
<div>{{ recipient.email | newline_to_br }}</div>
{% for field in recipient.custom_fields %}
<div>{{ forloop.length }}</div> <-- never enters for loop
<div>{{ field.label }}</div> <--- biller info doesn't print
<div>{{ field.text }}</div>
{% endfor %}
</td>
<td style="padding-right: 20px; text-align: right">
{% for field in fields %}
<div style="font-weight: bold">{{ field.label }}</div>
<div style="margin-bottom: 10px">{{ field.text }}</div>
{% endfor %}
{% for field in custom_fields %}
<div style="font-weight: bold">{{ field.label }}</div> <--- Test custom field does not print
<div style="margin-bottom: 10px">{{ field.text }}</div> <--- Test custom text does not print
{% endfor %}
</td>
</tr></table>
on the line:
{% for field in recipient.custom_fields %}
I have tried:
recipient.custom_fields
recipient.fields
recipient.custom_fields[0]
custom_fields
fields
The only thing that results in any printed content is fields
which takes the date, invoice and purchase number from the current invoice.
I can seem to print other recipient
info including email
but not custom fields
.
I would like the suppliers payment details (which I have in custom fields in the suppliers records) to be printed on the purchase invoice so that I no longer need to refer to the paper document once entered. I don’t want to have to re-enter these details into each and ever invoice as they don’t change.
Notwithstanding that, my purchase invoice custom field (test
) does not print either.
I also tried:
{% else %}
in the for loop
I can’t get the else
clause to work as indicated here (fourth last code sample at the bottom of the page) in this code:
# items => []
{% for item in items %}
{{ item.title }}
{% else %}
There are no items!
{% endfor %}
Trying else
results in:
DotLiquid.Exceptions.SyntaxException: for tag does not expect else tag
at DotLiquid.Block.UnknownTag (System.String tag, System.String markup, System.Collections.Generic.List`1[T] tokens) [0x0003f] in <6f84214986e446799758da986789ce21>:0
at DotLiquid.Block.Parse (System.Collections.Generic.List`1[T] tokens) [0x000f9] in <6f84214986e446799758da986789ce21>:0