How to Get Product/Product Variant SKUs to Show Up on Order Printer Invoice Template?

Highlighted
Tourist
6 0 2

Hello!

I'm trying to add into my invoice template (Order Printer app) a column for the product SKU and if the product has a variant SKU, to show that as well. Below is the code for my invoice template. I found in the code where the column headers are and was able to test add a column labeled SKU, but can't figure out how to get the SKUs to actually show up. :-/

 

Here is the template code...

______________________________________________________________

<p style="float: right; text-align: right; margin: 0;">
{{ "now" | date: "%m/%d/%y" }}<br />
Invoice for {{ order_name }}
</p>

<div style="float: left; margin: 0 0 1.5em 0;" >
<strong style="font-size: 2em;">{{ shop_name }}</strong><br /><br />
{{ shop.address }}<br/>
{{ shop.city }} {{ shop.province_code }} {{ shop.zip | upcase }}<br/>
{{ shop.country }}
</div>

<hr />

<h3 style="margin: 0 0 1em 0;">Item Details</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<thead>
<tr>
<th>Item</th>
<th>Quantity</th>
{% if show_line_item_taxes %}
<th>Taxes</th>
{% endif %}
<th>Price</th>
</tr>
</thead>
<tbody>
{% for line_item in line_items %}
<tr>
<td><b>{{ line_item.title }}</b></td>
<td>{{ line_item.quantity }} x</td>
{% if line_item.tax_lines %}
<td>
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }} {{ tax_line.title }}<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 note %}
<h3 style="margin: 0 0 1em 0;">Notes</h3>
<p>{{ note }}</p>
{% endif %}

<h3 style="margin: 0 0 1em 0;">Payment Details</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<tr>
<td>Subtotal price:</td>
<td>{{ subtotal_price | money }}</td>
</tr>
{% for discount in discounts %}
<tr>
<td>Includes discount "{{ discount.code }}"</td>
<td>{{ discount.savings | money }}</td>
</tr>
{% endfor %}
<tr>
<td>Total tax:</td>
<td>{{ tax_price | money }}</td>
</tr>
{% if shipping_address %}
<tr>
<td>Shipping:</td>
<td>{{ shipping_price | money }}</td>
</tr>
{% endif %}
<tr>
<td><strong>Total price:</strong></td>
<td><strong>{{ total_price | money }}</strong></td>
</tr>
{% if total_paid != total_price %}
<tr>
<td><strong>Total paid:</strong></td>
<td><strong>{{ total_paid | money }}</strong></td>
</tr>
<tr>
<td><strong>Outstanding Amount:</strong></td>
<td><strong>{{ total_price | minus: total_paid | money }}</strong></td>
</tr>
{% endif %}
</table>

{% if shipping_address %}
<h3 style="margin: 0 0 1em 0;">Shipping Details</h3>

<div style="margin: 0 0 1em 0; padding: 1em; border: 1px solid black;">
<strong>{{ shipping_address.name }}</strong><br/>
{% if shipping_address.company %}
{{ shipping_address.company }}<br/>
{% endif %}
{{ shipping_address.street }}<br/>
{{ shipping_address.city }}
{{ shipping_address.province_code }}
{{ shipping_address.zip | upcase }}<br/>
{{ shipping_address.country }}
</div>
{% endif %}

<p>If you have any questions, please send an email to <u>orders@earthenergycrystals.com</u></p>

______________________________________________________________

 

Thank you so much for your help. FYI, I'm totally new to code. Learning as I go. :-)

-Kathy

0 Likes
Highlighted
Shopify Staff
Shopify Staff
428 44 49

Hello, @Kathy_Everett.

 

Elias here with Shopify Support. Thank you for reaching out.

 

I understand you would like to add the SKU to the invoice template with Order Printer. You can do this by adding the variable ‘{{ line_item.sku }}’ onto your template and enclose them using an opening <td> and a closing </td> tag. 

 

Before we begin, there’s a couple things we should understand. The HTML table begins with <table> and ends with </table>, this indicates where the table starts and ends in the coding. You will notice that there are HTML <tr> tags, which defines the row in the table. HTML <th> tags, which defines the header in the table. And HTML <td> tags, which defines a standard cell in the table. The difference between <td> and <th> tags is that the <th> will appear as bolded. For our purpose of adding the SKU, we will only need to work with <th> tags for adding the SKU to the header and <td> tags with the variable to pull the SKU from the order. 

 

Here’s an example taken from my test store:

 

17-14-jes74-99bab

 

This is the preview of the invoice from a test order:

 

17-17-ettc6-d130d

 

Is this what you were looking for? I also noticed that there are a few duplicates of this question. If this answers your question, may I merge the other posts with this thread?

Elias | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
Highlighted
Tourist
6 0 2
This answers my question! Thanks so much for the learning moment!
1 Like