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.
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
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.
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
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.
@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