Adding date to footer

Hi,
I created a custom invoice with a footer which has a date (year) that is supposed to automatically change yearly. Since this is my first time using manager, I have to manually write the year there. What is the code to inserting the current year. Thank you

This isnā€™t intended to be a support forum for themes, but this might give you a starting point:

{% for field in fields %}
    {% if field.label == "Invoice date" %}
        {{ fields.text | date: "%Y" }}
    {% endif %}
{% endfor %}

Based on: date ā€“ Liquid template language - but keeping in mind that Managerā€™s fields are set up differently & have different names.

After a quick test, it doesnā€™t seem to work for me just yet, but with some minor tweaks you can probably find a solution.

1 Like

Thanks for the quick response. However just like you rightly said it didnā€™t work. Iā€™m not familiar with the programming language used to create manager so not sure I will be able to try anything else. Thanks for the help anyway. Hope to get someone to point in the right direction

You donā€™t need to know anything about .NET to work on themes. Just the Liquid templating syntax used by Shopify (and Manager).

Based on this comment, I assumed that you had already worked with Liquid syntax. If you havenā€™t, you may be better off hiring a professional to assist you.

The thing is Liquid is not that difficult, but there is a lot of guessing because of lack of documentation, right?

Thereā€™s a lot of documentation of Liquid. There main problem is that is not fully implemented in Manager and that we donā€™t have documents about how is implemented in Manager

Yup, that is what I meant: no documentation about managerā€™s implementation :slight_smile:

I still have not been able to find a solution. Hope to get someone here to help

{{ 'today' | date: 'yyyy' }}

This is what we use for a Date Printed tag on our invoices. Give that a shot and report back if it works for you.

1 Like

In that case, keeping @VISA-MC comment in mind, it might be something like this:

{% for field in fields %}
    {% if field.label == "Invoice date" %}
        {{ fields.text | date: 'yyyy' }}
    {% endif %}
{% endfor %}

Cc: @kofitalent

1 Like

Thanks @VISA-MC. It worked.

@ShaneAU @VISA-MC solution worked but will go ahead and test yours too. Anyway how different is yours from @ShaneAU solution?

Mine pulls the current date, @ShaneAU ā€˜s solution utilized the invoice date. [quote=ā€œkofitalent, post:1, topic:20356ā€]
I created a custom invoice with a footer which has a date (year) that is supposed to automatically change yearly.
[/quote]

I may have misunderstood this. Shaneā€™s solution will keep previous invoices displaying that year where mine would change that:
Example you raise an invoice in 2017 but look at it now, my code will display 2019 in that footer, whereas shaneā€™s Code will display 2017 in that footer.

Either way glad you got it working one way or another.

2 Likes

@VISA-MC. Ok ok I now get it. Thanks for the explanation.

I couldnā€™t get this to work. The result came out blank

Which option do you want? The year of the invoice or the current year?

The year of the invoice. The current year worked alright but the year of the invoice is not working

Which language are you using? Probably it doesnā€™t find ā€œInvoice dateā€ string.

English

You must not have copied it exactly. Here is the exact code from my test business:

        {% for field in fields %}
        {% if field.label == 'Invoice date' %}
            {{ field.text  | date: 'yyyy' }}
        {% endif %}
        {% endfor %}

and changed date for proof:

1 Like