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

Kathy_Everett
Tourist
6 0 3

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

Replies 13 (13)

Elias
Shopify Staff
2805 274 490

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

Kathy_Everett
Tourist
6 0 3
This answers my question! Thanks so much for the learning moment!
arkimports
Visitor
2 0 0

Thank you! that was very helpful. Do you know how I can add a quantity subtotal to the invoice as well? That would be super!!!!

Elias
Shopify Staff
2805 274 490

Greetings, @arkimports.

 

Thank you for joining the thread!

 

Just to confirm, are you looking to add the subtotal to the invoice? Or, are you looking to add a subtotal for when an order contains multiple quantities of a single variant?

 

If you're using Order Printer, then the default invoice template will contain the subtotal. However, if you're looking to add additional order information, such as line item properties for the individual variant subtotals, then this is something that our Theme Support team can look into for you. While we’re not able to provide account-specific support via the Shopify Community at this time, we’d be happy to continue assisting you through live chat, email, or callback. Please visit the Shopify Help Center and log in to your account to create a support request.

 

I'd love to know if our Theme Support can help you with this. Keep me posted!

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

eclipsegrafx
Visitor
1 0 0

Hi,

How do I now make the order sort by sku number? or what is the code to sort the order by the sku numbers?

Elias
Shopify Staff
2805 274 490

Hi, @eclipsegrafx.

 

Thank you for joining the thread!

 

I understand that you're looking to add the SKU onto your invoice and/or packing slips. Just to confirm, are you using Order Printer?

 

If so, then you can add the SKU onto Order Printer using the following variable: {{ line_item.sku }}. However, if you're looking to sort the order of items by SKU, then more custom coding will be likely be needed. While our Theme Support team can assist you with minor customizations, larger customizations would need to be done by an experienced third-party designer. Please visit the Shopify Help Center and log into your account to create a support request. From there, we'd be happy to assist you with a customization request through live chat, email, or callback.

 

That being said, if our Theme Support isn't able to assist you with this request, then you may need to consider hiring a developer if you're not comfortable working with coding languages (eg. HTML, CSS, JavaScript, and Liquid). If you need help finding a developer for your store, then we'd recommend taking a look at our directory of certified developers on Shopify Experts.

 

I noticed that you're a new member of our Shopify Community and I'd love to hear more about your business! What kinds of products are you selling? Do you have a marketing plan prepared for your store?

 

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

achesley84015
Visitor
2 0 0

No. I am looking to sort by sku. Yes I have contacted Shopify Support more than once. Nothing but dead ends. 

achesley84015
Visitor
2 0 0

Hi, I was wonder if you ever found any answers to sort by sku? I keep hitting dead ends with Shopify Support. 

 

Elias
Shopify Staff
2805 274 490

Hi, @achesley84015.

 

Thank you for joining the thread and posting this question!

 

I understand that you're looking for a way to sort by SKU on the notification templates. However, while our Theme Support can help with small cosmetic or text changes, you may need to consider hiring an expert for something more complicated like a sort by SKU function for the notifications. If you need help finding an expert, then we'd recommend taking a look at our directory of certified developers on Shopify Experts

 

If you have any other questions on this topic, then please don't hesitate to let me know!

 

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

Laura63653
Visitor
2 0 0

Hi Elias, I am really hoping you can help me! I would like to add my SKU to the packing list. I have managed to add my logo but can't seem to find the right code to add sku's next to each product name. Thank you

Elias
Shopify Staff
2805 274 490

Hi, @Laura63653.

 

Thank you for joining the thread!

 

I'm unable to access merchant accounts on the Shopify Community. However, if you're using the default packing slip or Order Printer, then you can use our packing slip variable reference. Should you require further assistance, then editing the packing slip is something that our Theme Support team can help you with using the 60 minutes of complementary design time included with our design policy. While we're unable to provide account-specific support via the Shopify Community as mentioned, we'd be happy to assist you with a customization request through live chats. Simply visit the Shopify Help Center and log into your account to create a support request. 

 

That being said, I noticed that you're a new member of our Shopify Community! I'd love to hear more about your business and share some resources to help you get started! 

 

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

AdaptiveTextile
Shopify Partner
7 0 0

@Laura63653 

Below is a bit of the template code from my own store, but it should have the variables you need. Mine is structured in a table, but maybe you can build and modify your own using it as a guide. I heavily modified the standard template code for more flexibility and customization. 

 

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<h3 style="margin: 0 0 1em 0; text-align: center;">Item Details</h3>

<thead>
<tr>
<th>Quantity</th>
<th>Product Image</th>
<th>Item</th>
<th>Sku</th>
{% if show_line_item_taxes %}
<th>Taxes</th>
{% endif %}
<th>Price</th>
</tr>
</thead>
<tbody>
{% assign sorted_line_items = line_items | sort: 'title' %}
{% for line_item in sorted_line_items %}
<tr>
<td style="font-size: 14px;">{{ line_item.quantity }} x</td>
<td><img src="{{ line_item.image | img_url: 'thumb' }}" /></td>
<td style="font-size: 14px;"><b>{{ line_item.title }}</b></td>
<td style="font-size: 14px;">{{ line_item.sku }}</td>
{% if line_item.tax_lines %}
<td style="font-size: 14px;">
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }} {{ tax_line.title }}<br/>
{% endfor %}
</td>
{% endif %}
<td style="font-size: 14px;">
{% 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>

AdaptiveTextile
Shopify Partner
7 0 0

@achesley84015 I hope this helps! For my own store, I created a table for all of the line items. Full disclosure, my code may not work for everyone, but at least it may give you ideas on how to implement it into your store. 

 

I've sorted by sku, title, and price by replacing the associated word in this chunk of code.

{% assign sorted_line_items = line_items | sort: 'sku' %}

 

Code with table below for sorting A to Z:

 

{% assign sorted_line_items = line_items | sort: 'sku' %}
{% for line_item in sorted_line_items %}

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<h3 style="margin: 0 0 1em 0; text-align: center;">Item Details</h3>

<thead>
<tr>
<th>Quantity</th>
<th>Product Image</th>
<th>Item</th>
<th>Sku</th>
{% if show_line_item_taxes %}
<th>Taxes</th>
{% endif %}
<th>Price</th>
</tr>
</thead>
<tbody>
{% assign sorted_line_items = line_items | sort: 'sku' %}
{% for line_item in sorted_line_items %}
<tr>
<td style="font-size: 14px;">{{ line_item.quantity }} x</td>
<td><img src="{{ line_item.image | img_url: 'thumb' }}" /></td>
<td style="font-size: 14px;"><b>{{ line_item.title }}</b></td>
<td style="font-size: 14px;">{{ line_item.sku }}</td>
{% if line_item.tax_lines %}
<td style="font-size: 14px;">
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }} {{ tax_line.title }}<br/>
{% endfor %}
</td>
{% endif %}
<td style="font-size: 14px;">
{% 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>

 

 

 to sort Z to A replace the top section with 

{% assign sorted_line_items = line_items | sort: 'title' | reverse %}

{% for line_item in sorted_line_items %}