Hey @Wiji77, welcome to the community.
You're actually on the right track, but the issue comes from the fact that you're referencing specific indexes in the fulfilments array. Since some orders have a gift card and some don't, the tracking number's position in the array is not consistent.
The suggested approach is to loop through the fulfilments and find the first available tracking number. Try this:
liquid
Copy
Edit
{% for fulfilment in event.extra.fulfilments %}
{% if fulfilment.tracking_number != blank %}
{{ fulfilment.tracking_number }}
{% break %}
{% endif %}
{% endfor %}
This will go through all fulfilments in the order and display the first tracking number it finds, skipping empty ones (like the gift card). The {% break %} ensures it stops as soon as it finds one.
Let me know if this helps?
Hey @Wiji77, welcome to the community.
You're actually on the right track, but the issue comes from the fact that you're referencing specific indexes in the fulfilments array. Since some orders have a gift card and some don't, the tracking number's position in the array is not consistent.
The suggested approach is to loop through the fulfilments and find the first available tracking number. Try this:
liquid
Copy
Edit
{% for fulfilment in event.extra.fulfilments %}
{% if fulfilment.tracking_number != blank %}
{{ fulfilment.tracking_number }}
{% break %}
{% endif %}
{% endfor %}
This will go through all fulfilments in the order and display the first tracking number it finds, skipping empty ones (like the gift card). The {% break %} ensures it stops as soon as it finds one.
Let me know if this helps?
Thank you very much for your feedback. It's really nice.
It's all quite new to me and I didn't quite understand (ahah sorry).
I have to put :
{% for fulfilment in event.extra.fulfilments %}
{% if fulfilment.tracking_number != blank %}
{{ fulfilment.tracking_number }}
{% break %}
{% endif %}
{% endfor %}
In my email template, where do I want to display my tracking number?
Thanks again and sorry if my questions are a bit ‘simple’.
Hey @Wiji77,
Happy to step in for Mansir! You’d add that code into a text block or in the text section of a table/split, wherever you want the tracking number to be displayed. Mansir made what’s called a “for loop” which displays certain text for every item in an event (in this case, for every fulfillment in your fulfilled order metric). If an item in your event data has a tracking number, it’ll show that number, and then check to see if the next item has a tracking number. If that next item has a tracking number, it’ll show it, and so on.
I’d recommend adding that to your template and checking to see if the tracking numbers display in the preview. If not, let us know, and we can work on another potential solution!
-Byrne
Hello, I want my tracking number to appear when I place an order, how can I do it?
Hey @Wiji77, welcome to the community.
You're actually on the right track, but the issue comes from the fact that you're referencing specific indexes in the fulfilments array. Since some orders have a gift card and some don't, the tracking number's position in the array is not consistent.
The suggested approach is to loop through the fulfilments and find the first available tracking number. Try this:
liquid
Copy
Edit
{% for fulfilment in event.extra.fulfilments %}
{% if fulfilment.tracking_number != blank %}
{{ fulfilment.tracking_number }}
{% break %}
{% endif %}
{% endfor %}
This will go through all fulfilments in the order and display the first tracking number it finds, skipping empty ones (like the gift card). The {% break %} ensures it stops as soon as it finds one.
Let me know if this helps?
Thank you very much for your feedback. It's really nice.
It's all quite new to me and I didn't quite understand (ahah sorry).
I have to put :
{% for fulfilment in event.extra.fulfilments %}
{% if fulfilment.tracking_number != blank %}
{{ fulfilment.tracking_number }}
{% break %}
{% endif %}
{% endfor %}
In my email template, where do I want to display my tracking number?
Thanks again and sorry if my questions are a bit ‘simple’.
Hello, I want my tracking number to appear when I place an order, how can I do it?
Hey, if you want to show the tracking number in the post-purchase emails, make sure : you are using a flow email triggered by fulfilled order (not just placed order), because tracking numbers are usually added at the fulfilment stage, then you can insert this liquid code in your template : {% for fulfilment in event.extra.fulfilments %}
{% if fulfilment.tracking_number != blank %}
Track your order: {{ fulfilment.tracking_number }}
{% break %}
{% endif %}
{% endfor %}
this is what have worked for my client but if you are still seeing nothing , you can wait until the fulfilment is processed or check if your test order has a tracking number assigned yet. Let me know how it goes! @Franco