Hello! I am working on a Refund Template using Order Printer. I have the date in which the order was made (Bestelldatum) and want to display a different date for when the refund is made. I cannot figure out how to this in the code. Can someone please help?
For the order date (the date in which the order was made) I am using:
<li class="order-details-date">
<span class="order-details-title editable" data-key="date"> Bestelldatum</span>
<span class="order-details-text">{{ processed_at | date: "%d.%m.%Y" }}</span>
</li>
If the customer sends the order back and a refund is made, I need to display the date in which the refund was applied (Gutschrift Datum).
Attached is a screenshot of what it looks like at the moment.
I cannot find the right Variable for that. I would appreciate help ASAP as this is for a client who needs it urgently for taxing purposes. Thanks so much!
Not 100% clear on your requirement here, but have you seen this
https://shopify.dev/docs/admin-api/graphql/reference/orders/refund
Are you looking for refund.created_at?
Regards
Peter
@peterloanesorry for the late reply. Here is the code I used for the refund date "Gutschrift Datum":
<li class="order_details">
<span class="order-details-title editable" data-key="number"> Gutschrift-Nr. </span>
{% for transaction in refund_transactions %}
GS{{ order_number }}-1000
{% endfor %}
</li>
<li class="order-details">
<span class="order-details-title editable" data-key="date"> Gutschrift Datum</span>
{% for transaction in refund_transactions %}
{{ transaction.date | date: "%d.%m.%Y" }}
{% endfor %}
</li>
<li class="order-details-date">
<span class="order-details-title editable" data-key="date"> Bestelldatum</span>
<span class="order-details-text">{{ processed_at | date: "%d.%m.%Y" }}</span>
</li>
I now have a different challenge, maybe you can help me? For the "Gutschrift-Nr." (Refund Nr.) I want to display a string with the number 1000 that always increases. This is for taxing purposes. For example the first refund would have the number GS{{ order_number }}-1000, the second refund GS{{ order_number }}-1001, the third GS{{ order_number }}-1002 and so on. I don't know how to do this in a way that catches all the refunds in the system and creates this linear sequence of increasing numbers. Any ideas? Thanks so much!
Have you seen this https://shopify.github.io/liquid/tags/variable/ ?
Increment looks like it might be useful
Also some examples here https://www.twilio.com/docs/studio/user-guide/liquid-template-language might be useful
So something like this, but note I have not tested the ideas
{% assign offset = 1000 %}
{% for transaction in refund_transactions %}
GS{{ order_number }}-{{ {% increment var %} | plus:offset }}
{% endfor %}
Regards
Peter
Heres a tested example version
{% assign offset = 1000 %}
{% for i in (0..4) %}
GS{{ i }}-{{offset|plus:i}}
{% endfor %}
Here is the output
" GS0-1000 GS1-1001 GS2-1002 GS3-1003 GS4-1004 "
Detail from interactive Ruby shell below
irb(main):056:0> @template = Liquid::Template.parse('{% assign offset = 1000 %} {% for i in (0..4) %} GS{{ i }}-{{offset|plus:i}} {% endfor %}')
irb(main):057:0> @template.render()
=> " GS0-1000 GS1-1001 GS2-1002 GS3-1003 GS4-1004 "
@peterloanethank you so much for getting back to me! The thing is I need that the refund receipts have a progressing number. This is for taxing purposes. So the first receipt need to have the order number and then "1000", the second one again the order number and "1001", the third one order number "1002", and so on. The code you provided is very cool but all my receipts would end up having the same number at the end which is not what I am looking for. Do you have any other ideas? I checked the documentation but haven't found anything so far... I greatly appreciate your time and help!
Hi @Elisaw
Try this then
{% assign offset = 1000 %}
{% for transaction in refund_transactions %}
GS{{ order_number }}-{{offset}}
{% assign offset = offset|plus:1 %}
{% endfor %}
Regards
Peter
User | Count |
---|---|
27 | |
23 | |
22 | |
19 | |
10 |