A space to discuss online store customization, theme development, and Liquid templating.
When displaying a customer's order (via the customer's account page, i.e. in customers/order.liquid) I need to also display which items in the order have been returned.
I'm able to get to access an order.refunds object which has some brief info about the refunds on the order. This gives me "Internal error" the first time I access its subcomponents (but then I can access them).
When I look at the info that is provided for each refund, I can see an id and a quantity, but the id doesn't correspond with a line item. So, there's no way for me to match the refunded items back again.
How can I access and display refunds for each order?
Steve
You can try this one:
{%- for line_item in order.line_items -%}
{%- if line_item.fulfillment -%}
<div class="fulfillment">
{%- assign created_at = line_item.fulfillment.created_at | time_tag: format: 'date' -%}
<span>{{ 'customer.order.fulfilled_at_html' | t: date: created_at }}</span>
{%- if line_item.fulfillment.tracking_url -%}
<a href="{{ line_item.fulfillment.tracking_url }}">
{{ 'customer.order.track_shipment' | t }}
</a>
{%- endif -%}
<span>
{{ line_item.fulfillment.tracking_company }}
{%- if line_item.fulfillment.tracking_number -%} #{{ line_item.fulfillment.tracking_number }} {%- endif -%}
</span>
</div>
{%- endif -%}
{% for line in order.subtotal_line_items %}
{% if line_item.id == line.id %}
{% if line.refunded_quantity > 0 %}<div class="fulfillment"><span class="order-list__item-refunded">Refunded {{ line.refunded_quantity | default:0 }}</span></div>{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
It's working in Dawn theme after add above code:
Hey there Modi, I've just starting to learn Liquid and I was able to account for returned items thanks to your code. Much appreciated.
However I couldn't find any reference in the dev docs to the refunded_quantity property you used. So the code works, but I'm not sure why.
Is this an undocumented property?