Hi’
Can someone help me in creating a Credit note template which is deemed assumed as a return invoice in Switzerland?
As a beginner Shopify user, I came across to Order printer as a free to create my accounting documents. IT has 2 default templates Invoice and packing Slip. With aesthetic changes I am using the skeleton of those templates which work.
Now I need a third template which needs ot be issued when the order is returned. This will need to show the line items/ products that re returned their value (including the discounts) applied and show minus figures also quantity that are returned by the customer. This needs to be shared to the customer together with the refund notification.
But every time I get zero information as the fields of line items come zero. No refund items are captured.
{{ line_item.title }}
{{ line_item.sku }}
{{ line_item.quantity }}
{{ line_item.price | money }}
{{ line_item.line_price | money }}
Where do I make a mistake?
I use the template on old orders that were returned to test the template. It always gives zero information.
I am not sure if it is a coding issue or access issue of Order Print to Shopify return data or a bug in shopify or something I do in returning process in shopify? I am lost. Any help is appreciated.
Hi there,
This is Jay from Fast Bunde. I hope you are doing well.
The main problem seems to be that when you’re testing the template on old returned orders, the line_item fields (e.g., {{ line_item.quantity }} or {{ line_item.line_price }}) return zero values. This could be due to how Shopify handles returns versus orders and how the data is accessible to the Order Printer app.
Possible Causes:- Access to Return Data: Order Printer might not have access to specific return data by default. The app typically works with the order data but may not include return-specific details (like refunded items or quantities).
- Coding Issue in the Template: If the template doesn’t account for return/refund data fields specifically, it could result in zero values.
- Test Orders vs. Real Returns: When testing the template on past orders, ensure those orders have properly processed returns. Otherwise, the return data may not exist for those orders.
Solution Steps:
a) Check Return Data Availability
Shopify’s line_item object in Order Printer templates reflects items in the original order, but refund/return details are handled separately in Shopify. The return-specific data might need to be accessed through the refunds object. For example:
{% for refund in refunds %}
{% for refunded_line_item in refund.refund_line_items %}
<tr>
<td>{{ refunded_line_item.line_item.title }}</td>
<td>{{ refunded_line_item.line_item.sku }}</td>
<td>{{ refunded_line_item.quantity }}</td>
<td>{{ refunded_line_item.line_item.price | money }}</td>
<td>-{{ refunded_line_item.subtotal | money }}</td>
</tr>
{% endfor %}
{% endfor %}
This loops through refunds and pulls details for refunded line items. It will show:
- The title of the returned product
- SKU
- Quantity returned
- Original price
- Subtotal as a negative value (refund amount).
Make sure to replace your current line_item references with refunded_line_item when displaying return data.
b) Update Your Template Logic
Since you’re creating a credit note template, you’ll want it to:
- Display only refunded items, not all items in the order.
- Format the returned quantities and amounts as negatives.
- Clearly state that it’s a credit note.
You can adapt your template to focus on refunds like this:
<table>
<thead>
<tr>
<th>Product</th>
<th>SKU</th>
<th>Quantity Returned</th>
<th>Original Price</th>
<th>Refund Amount</th>
</tr>
</thead>
<tbody>
{% for refund in refunds %}
{% for refunded_line_item in refund.refund_line_items %}
<tr>
<td>{{ refunded_line_item.line_item.title }}</td>
<td>{{ refunded_line_item.line_item.sku }}</td>
<td>{{ refunded_line_item.quantity }}</td>
<td>{{ refunded_line_item.line_item.price | money }}</td>
<td>-{{ refunded_line_item.subtotal | money }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
c) Test on Proper Returns
Make sure you’re testing the template on orders that have valid return/refund data. If no refunds exist for an order, the refunds object will be empty, and the template will appear to return zero information.
Double-Check Shopify Return Process- Confirm that you’re properly marking items as returned in Shopify. This involves creating a return and issuing a refund within the Shopify admin for the order.
- If returns are not being created correctly, no data will populate in the refunds object.
Consider Limitations of Order Printer
If the above doesn’t work, it’s possible that Order Printer simply doesn’t have access to return-specific data. In this case:
- You could look into a third-party app that specializes in creating credit notes or handling returns.
- Alternatively, you might need custom development to create a more robust solution.
1 Like
thank you for enlightening me about this new fields. With the help of CHARGPT I have implemented this code and it finally brought the line items and the quanities but not the unit price or the total money value that needs to be refunded. Any ideas?
I follow the stnadard return procedure in Shopify. I have no problem in return process other than this weird return notification that Shopify creates. After reading some forum topics about the autoamted return request on teh customer account page. I began to worry .
again any help is appreciated
Thanks indeed
1 Like
EDIT: I was having the same issue. After working with the Shopify AI bot to help me with liquid coding, the key was to display the “original price” of the returned item. Below is the key parts of code suggested. Additionally I have found that collaborating with the Shopify AI for liquid coding is better than ChatGPT since it is more familair, and you can also ask it to test the code against your existing orders in your store which it will!
{% for refund in order.refunds %}
{% for refund_line_item in refund.refund_line_items %}
{% assign original_line_item = order.line_items | where: "id", refund_line_item.line_item.id | first %}
{% if original_line_item %}
{{ original_line_item.price | money }}
{% else %}
{% if refund_line_item.subtotal %}
{{ refund_line_item.subtotal | divided_by: refund_line_item.quantity | money }}
{% elsif refund_line_item.total_price %}
{{ refund_line_item.total_price | divided_by: refund_line_item.quantity | money }}
{% elsif refund.amount %}
{{ refund.amount | divided_by: refund_line_item.quantity | money }}
{% else %}
{{ refund_line_item.line_item.original_price | money }}
{% endif %}
{% endif %}
{% if original_line_item %}
{{ original_line_item.price | times: refund_line_item.quantity | money }}
{% else %}
{% if refund_line_item.subtotal %}
{{ refund_line_item.subtotal | money }}
{% elsif refund_line_item.total_price %}
{{ refund_line_item.total_price | money }}
{% elsif refund.amount %}
{{ refund.amount | money }}
{% else %}
{{ refund_line_item.line_item.original_price | times: refund_line_item.quantity | money }}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}