How to place a total at the top of a page above any other code

Which code can you use to place a total amount at the top of a page, so above any other code.
I tried with assign and with $ but that does not work.

Hi @NickS,

When the total amount is calculated within the template, it will not display above the calculation as liquid-code reads from top to bottom. A simple way to show the total amount on top is to capture the input or calculation, and display it underneath the total amount. Please find a simple example hereafter:

{% capture inputfields %}
{% $0+input as:integer %}
{% $0+input custom.number.two as:integer %}
{% endcapture %}

{{ $0 | integer }}

{{ inputfields }}

However, in the above example it is also possible to calculate the total amount as follows:

{{ | integer }}
{% input as:integer %}
{% input custom.number.two as:integer %}

This way, the total amount will show on top of the page, as the ‘custom.’ input is a database variable, which can be displayed anywhere.

Hope this helps!

Kind regards,

Hi @robindeclercq

Have a nice day.