Printing refunds to Printrooster template
If your order has refunds in it and you want to print those to your Printrooster Order template, the following code does this for you
{% assign refund_total = 0 %}
{% for refund in refunds %}
{% for refund_line_item in refund.refund_line_items %}
{% assign refund_value = refund_line_item.amount_set.shop_money.amount | times: refund_line_item.quantity %}
{% assign refund_total = refund_total | plus: refund_value %}
{% endfor %}
{% endfor %}
{% if refund_total %}
<tr>
<td><b>Refunds</b></td>
<td>{{ refund_total | money }}</td>
</tr>
{% endif %}
Here we have first assigned a total sum of refunds to a variant of refund_total, then calculate the total amount of refunds found in the order. If there are refunds, a refund_total is printed.
This snippet of code can be used, for example, in the subtotal section of the order template
