Solved

{{ line_item.fulfillment.tracking_number}} doesnt work on order view?

mariosolis
Tourist
10 1 1

hi im trying to add {{ line_item.fulfillment.tracking_number}} to display shipping tracking number and company to Order Printer plugin wich handles order viewing and printing but it just ignores it, i even made sure to use a working real fedex tracking number but it just gets ignored, does the liquid tag got obsolete? 

Accepted Solution (1)
mariosolis
Tourist
10 1 1

This is an accepted solution.

<td style="width: 49%;">
                    {% for line_item in line_items %}
                    {% if line_item.fulfillment.tracking_number %}
                    <b>Fecha estimada de entrega: {{ fulfillment.tracking_number }}<br>
                    <b>Compañía: {{ line_item.fulfillment.tracking_company }} <br>
                    Numero de rastreo: <a href="{{ line_item.fulfillment.tracking_url }}" target="_blank"> #{{ line_item.fulfillment.tracking_number}}</a></br>
                    {% endif %}
                    <br>
                    {% endfor %}
                </td>   

solved it, i had to change the for cycle, just removed the "order." and its back on rails, thanks for the support

View solution in original post

Replies 13 (13)

gseilei
Shopify Expert
235 28 44

Hey, you will probably need to add this to your code first:

 

{% for line_item in order.line_items %}
 
....
 
{% endfor %} 
 
Could you try and let me know if that helps? Otherwise you could maybe post the code here where you have these troubles!
We help you achieve your Goals! Visit us on: Webmefy.com
mariosolis
Tourist
10 1 1
<p style="float: right; text-align: right; margin: 0;">
  {{ date | date: "%d/%m/%Y - %I:%M%p" }}<br />
  Pedido {{ order_name }}
</p>

<div style="float: left; margin: 0 0 1.5em 0;" >
  <strong style="font-size: 2em;"><img src="https://ci4.googleusercontent.com/proxy/Eznt9wVr1viWeMbLisiBO40Ng0Oym06Pvc7mI73B8jQ-IRdi95Y4If9Sgn4ACXheWrd8QZglFnriqDTfTQDJNE-qGYQnJHPdx3Z5sxZUsU3Edd4FEbN4k04AIAKrAUTfx2ujnU7-z7uVh4U9Nw=s0-d-e1-ft#https://cdn.shopify.com/s/files/1/0045/0700/9096/email_settings/Dilmun_logo_350px.jpg?2007" width="150">
</strong><br />
  {{ shop.address }} #{{ shop.address2 }}<br/>
  {{ shop.city }}<br/>
  {{ shop.country }}, {{ shop.province_code }}<br>
  {{ shop.zip | upcase }}
</div>

<hr />

<h3 style="margin: 0 0 1em 0;">Detalle de pedido</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
  <thead>
    <tr>
      <th>Cantidad</th>
      <th>Artículo</th>
      {% if show_line_item_taxes %}
      <th>Impuestos</th>
      {% endif %}
      <th>Precio</th>
    </tr>
  </thead>
  <tbody>
    {% for line_item in line_items %}
      <tr>
        <td>{{ line_item.quantity }} x</td>
        <td>{{ line_item.title }}</td>
        {% if line_item.tax_lines %}
          <td>
            {% for tax_line in line_item.tax_lines %}
              {{ tax_line.price | money }} <br/>
            {% endfor %}
          </td>
        {% endif %}
        <td>
          {% if line_item.original_price != line_item.price %}
            <s>{{ line_item.original_price | money }}</s>
          {% endif %}
          {{ line_item.price | money }}
        </td>
      </tr>
    {% endfor %}
  </tbody>
</table>

{% if transactions.size > 1 %}
  <h3 style="margin: 0 0 1em 0;">Detalle de transacciones</h3>
  <table class="table-tabular" style="margin: 0 0 1.5em 0;">
    <thead>
      <tr>
        <th>Tipo</th>
        <th>Cantidad</th>
        <th>Especie</th>
        <th>Estado</th>
      </tr>
    </thead>
    <tbody>
      {% for transaction in transactions %}
        <tr>
          <td>{{ transaction.gateway | payment_method }}</td>
          <td>{{ transaction.amount | money }}</td>
          <td>{{ transaction.kind }}</td>
          <td>{{ transaction.status }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endif %}

<h3 style="margin: 0 0 1em 0;">Detalle del pago</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
  <tr>
    <td>Subtotal:</td>
    <td>{{ subtotal_price | money }}</td>
  </tr>
  {% for discount in discounts %}
  <tr>
    <td>Incluye descuento "{{ discount.code }}"</td>
    <td>{{ discount.savings | money }}</td>
  </tr>
  {% endfor %}
  <tr>
    <td>Impuestos:</td>
    <td>{{ tax_price | money }}</td>
  </tr>
  {% if shipping_address %}
    <tr>
      <td>Envío:</td>
      <td>{{ shipping_price | money }}</td>
    </tr>
  {% endif %}
  <tr>
    <td><strong>Total:</strong></td>
    <td><strong>{{ total_price | money }}</strong></td>
  </tr>
  {% if total_paid != total_price %}
    <tr>
      <td><strong>Total pagado:</strong></td>
      <td><strong>{{ total_paid | money }}</strong></td>
    </tr>
    <tr>
      <td><strong>Gran Total:</strong></td>
      <td><strong>{{ total_price | minus: total_paid | money }}</strong></td>
    </tr>
  {% endif %}
</table>

{% if note %}
  <h3 style="margin: 0 0 1em 0;">Nota</h3>
  <p>{{ note }}</p>
{% endif %}

{% if shipping_address %}
  <h3 style="margin: 0 0 1em 0;">Detalles del envío</h3>

<div style="margin: 0 0 1em 0; padding: 1em; border: 1px solid black;">
  <table>
	   <tbody>
		     <tr>
			    <td style="width: 49%;">  
                    <strong>{{ shipping_address.name | upcase  }}</strong><br/>
                    {% if shipping_address.company %}
                    {{ shipping_address.company }}<br/>
                    {% endif %}
                    {{ shipping_address.street }}<br/>
                    {{ shipping_address.city }}, {{ shipping_address.country }}<br>
                    {{ shipping_address.zip | upcase }}
                </td>
                <td style="width: 49%;"><b>Fecha estimada de entrega: {{ fulfillment.tracking_number }}<br>
                Numero de rastreo: 
              {% for line_item in order.line_items %}
                {% if line_item.fulfillment.tracking_number %}
                    <a href="{{ line_item.fulfillment.tracking_url }}" target="_blank">{{ 

line_item.fulfillment.tracking_company }} #{{ line_item.fulfillment.tracking_number}}</a>
                {% endif %}
                <br>
              {% endfor %}
            </td>   
        </tr>
    </tbody>
  </table>
</div>


{% endif %}

<p align="center">Si tienes alguna duda, por favor envía un correo a <u>{{ shop.email }}</u>
<h3 align="center" style="margin: 0 0 1em 0;">Gracias por comprar en Dilmun</h3></p>

heres the code, thanks!!

gseilei
Shopify Expert
235 28 44

y si estás seguro de que la orden en la que lo estás probando tiene un número de tracking disponible?

We help you achieve your Goals! Visit us on: Webmefy.com
mariosolis
Tourist
10 1 1

hola, si de hecho incluso agregué un numero de rastreo valido que use hace unas semanas

PaulNewton
Shopify Partner
6274 573 1319
  • Verify Data exists at all
  • Verify existence of data in the context your using
  • Verify Conditionals

 

If your not getting output on something , next verify data, here confirm an order that you know has a tracking url

shopify.com/admin/api/2019-04/orders/#{order_id}/fulfillments.json

 

Also which specific file are you trying to add this to? See the email variables reference for notifications as I believe fulfillment variables are only allowed in some notification templates.

 

Verify your conditionals are even working:

            {% for line_item in order.line_items %}
                {% if line_item.fulfillment.tracking_number %}
                  TestString                {% endif %}
                <br>              {% endfor %} 

 

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


mariosolis
Tourist
10 1 1

im trying to add this information to order template, not to be confused with email notifications, i tried the json address but it gives me a https error and the browser wont allow me any further

PaulNewton
Shopify Partner
6274 573 1319

@mariosolis wrote:

im trying to add this information to order template,

customers/order.liquid?

 


@mariosolis wrote:

i tried the json address but it gives me a https error and the browser wont allow me any further


You have to add the proper order id and updated it for your store

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


mariosolis
Tourist
10 1 1

@PaulNewton wrote:

@mariosolis wrote:

im trying to add this information to order template,

customers/order.liquid?

 


@mariosolis wrote:

i tried the json address but it gives me a https error and the browser wont allow me any further


You have to add the proper order id and updated it for your store


its order template, main dash myshopify area you click on "orders",  then on the order number, inside the order resume and preview theres a "more actions" option i select "Print with Order Printer" and shows me a sort of printable form filled with the order info, on the right side of it says "Edit" and thats where i found the code, it cohabits with the shipping sticker (packing slip) template if that helps locating it

mariosolis
Tourist
10 1 1

This is an accepted solution.

<td style="width: 49%;">
                    {% for line_item in line_items %}
                    {% if line_item.fulfillment.tracking_number %}
                    <b>Fecha estimada de entrega: {{ fulfillment.tracking_number }}<br>
                    <b>Compañía: {{ line_item.fulfillment.tracking_company }} <br>
                    Numero de rastreo: <a href="{{ line_item.fulfillment.tracking_url }}" target="_blank"> #{{ line_item.fulfillment.tracking_number}}</a></br>
                    {% endif %}
                    <br>
                    {% endfor %}
                </td>   

solved it, i had to change the for cycle, just removed the "order." and its back on rails, thanks for the support

PaulNewton
Shopify Partner
6274 573 1319

Nice, good work we should have been tipped off earlier: "for line_item in line_items" is also used at the start of your code immediately after the <tbody>

 

To clarify line_items is an object available in notification templates, otherwise order.line_items while accessing an order in an orders array

e.g. inside a for loop going over orders that then go over line items

So is in other areas for example:

{% for order in customer.orders %}
{% for line_item in order.line_items %}

So if your not inside an orders loop, then order.line_items isn't anything nor is line_items normally.

 

 

 

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


teonsight
Visitor
3 0 0

Hi,

is this solution still working?
I tried it in the Invoice default template of Order Printer app:

[...]

  <thead>
    <tr>
        <th>Fullf</th>
      <th>Quantity</th>
      <th>Item</th>
      {% if show_line_item_taxes %}
      <th>Taxes</th>
      {% endif %}
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    {% for line_item in line_items %}
    
      <tr>
        <td>
            {% if line_item.fulfillment.tracking_number %}
            <b>Fecha estimada de entrega: {{ fulfillment.tracking_number }}<br>
            <b>Compañía: {{ line_item.fulfillment.tracking_company }} <br>
            Numero de rastreo: <a href="{{ line_item.fulfillment.tracking_url }}" target="_blank"> #{{ line_item.fulfillment.tracking_number}}</a></br>
            {% endif %}
        </td>   
        <td>{{ line_item.quantity }} x</td>

[...]

  but I get "Liquid error: internal"

Thanks

Bguided
New Member
4 0 0

Me too!  Can anyone help?  I'm just getting Internal error

AshL_11
Visitor
1 0 1

Just incase it comes in useful to someone I also tried the solutions above to get the tracking number and shipping company to show in the Shopify Order Printer app but none of them worked. Below is the code that I stumbled upon that worked for me, Shopify must have changed something because it's completely different to the code posted in older posts but it works.   

 

{% if fulfillment_status == 'fulfilled' %}
{% for fulfillment in fulfillments %}
{{ fulfillment.tracking_company }}:&nbsp;{{ fulfillment.tracking_number }}
{% endfor %}
{% endif %}