How can I display shipping method and tracking number in order history?

Topic summary

Goal: show shipping method and tracking number in the customer order history table.

Key steps and outcomes:

  • Initial attempt added a new column and used {{ fulfillment.tracking_number }}, which returned nothing because it didn’t reference a specific fulfillment within items/orders.
  • Working approach: loop through each order’s line items and read fulfillment data:
    • Display {{ line_item.fulfillment.tracking_company }} and, if present, {{ line_item.fulfillment.tracking_number }}.
  • Duplicate issue (same tracking shown for multiple products) solved by breaking the loop after the first match:
    • Inside the loop, check if tracking_number exists, output the data, then use {% break %} to show it only once.
  • Placement: add the code in the customer account template (templates → customers/account.liquid or sections/account.liquid) inside the {% for order in customer.orders %} table row.

References: a Shopify docs link to order.shipping_methods was shared, but the final working code uses line_item.fulfillment fields.

Status: resolved. Working code confirmed; duplication mitigation and file location guidance provided.

Summarized with AI on December 14. AI used: gpt-5.

Try these instead @ariesto

 <th>Shipping Method</th>
<td> 
    {%- for line_item in order.line_items -%}
        <div>
            {{ line_item.fulfillment.tracking_company }}
            {%- if line_item.fulfillment.tracking_number -%} #{{ line_item.fulfillment.tracking_number }} {%- endif -%}
        </div>
    {%- endfor -%}
</td>
1 Like