How can I display a separate refund date using Order Printer?

Elisaw
Explorer
79 2 11

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.

Screen Shot 2021-01-26 at 2.02.26 PM.png

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!

Replies 12 (12)

peterloane
Shopify Partner
44 5 14

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

Elisaw
Explorer
79 2 11

Thank you Peter that´s a good tip!

Elisaw
Explorer
79 2 11

@peterloaneI found another solution but thanks so much! I will keep that for the future 🙂

peterloane
Shopify Partner
44 5 14

@Elisaw cool

Feel free to message if its shareable. Glad you made progress.

 

Peter

 

Elisaw
Explorer
79 2 11

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

peterloane
Shopify Partner
44 5 14

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

peterloane
Shopify Partner
44 5 14

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 " 

Elisaw
Explorer
79 2 11

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

peterloane
Shopify Partner
44 5 14

Hi

I expect the last code snip still has a problem for you. Some questions to clarify

1: Does the refund receipt number always increment? or for example reset to 1000 at the start of each tax year?

2: If it always increases what happens at 9999? Does it extend to 5 digits etc?

Regards

Peter

 

Elisaw
Explorer
79 2 11

@peterloanein response to your questions:

 

1: Does the refund receipt number always increment? or for example reset to 1000 at the start of each tax year?

Not necessarily

2: If it always increases what happens at 9999? Does it extend to 5 digits etc?

Yes, that would be an option 🙂

peterloane
Shopify Partner
44 5 14

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

Elisaw
Explorer
79 2 11

@peterloaneAlso doesn't work... I asked someone else and they told me this is not possible with Shopify Apps, since there is no way of tracking the number of refunds and calling them in the code in this way. If you think otherwise please let me know! Thanks so much