How do I add SKUs to customer order notification emails?

Topic summary

A user working with the Dawn theme successfully added SKUs to staff order notification emails using conditional Liquid code that checks if line.sku is not blank.

However, when attempting to add SKUs to customer order notification emails using simplified code ({% if line.sku != blank %} SKU: {{ line.sku }} {% endif %}), the SKUs appear in the email preview but fail to display in actual customer notification emails sent after test orders.

Current Status:

  • Staff notifications: Working correctly
  • Customer notifications: Not working (preview shows SKUs, live emails do not)

The user acknowledges limited coding experience and used ChatGPT to generate the code. They are seeking suggestions to resolve why the SKU display works in preview but not in actual customer emails.

Summarized with AI on October 30. AI used: claude-sonnet-4-5-20250929.

I am using Dawn theme and am trying to add SKU’s to order notification emails directly under the product titles of added items. I was able to successfully add it to staff order notification emails using the following code:

{% if line.sku != blank %}

{% endif %}
{% elsif line.variant.title != ‘Default Title’ and line.bundle_parent? and expand_bundles == false %}
{{ line.variant.title | replace: ’ / ', ‘-’}}

  {% if line.sku != blank %}
    <span class="order-list__item-variant">• </span>
  {% endif %}
{% endif %}

{% if line.sku != blank %}
  <span class="order-list__item-variant">SKU: {{ line.sku }}</span>
{% endif %}

I then tried the below code in the customer order notification emails, and while the SKU’s show up in the preview, they do not show up in the customer notification email when I test an order.

{% if line.sku != blank %}
SKU: {{ line.sku }}
{% endif %}

I am not great with code and used chatgpt for the above, so would appreciate it if anyone has some suggestions. Thank you.

1 Like

Hey @kristd

Thanks for posting this to the Shopify Community.
To display the SKU under each product title in your customer order notification emails (for the Dawn theme), you can modify the order confirmation email template in your Shopify admin.

Here’s what you can do:

  1. Go to Settings → Notifications → Order Confirmation.

  2. Click Edit Code.

  3. Find the section where the product line items are listed (usually inside {% for line in line_items %} loop).

  4. Just below the product title, insert the following code:

{% if line.sku != blank %}
  <p style="margin: 0; font-size: 14px; color: #555;">
    SKU: {{ line.sku }}
  </p>
{% endif %}

This will show each product’s SKU directly under the product title in the order email.

The code you mentioned is mainly used for staff notifications, but for customer-facing emails, the above snippet works best within the correct loop.

In order to confirm the right placement for your specific email template, could you please share your email template code snippet (around where product titles appear) so I can guide you exactly where to paste it?

Waiting to hear back from you.
If this was helpful, don’t forget to like it and mark it as a solution.

Thanks

1 Like

Hi @TheScriptFlow_1 Thank you so much for your response. I tried your suggestion but unfortunately ran into the same issue where it displays when I preview the email, but when I submit an order to test it, the SKUs do not show up.

I also realized my original code did not paste correctly. The code I originally entered was:

{% if line.sku != blank %}
  <span class="order-list__item-sku" style="font-size:14px; color:#999;">SKU: {{ line.sku }}</span><br/>
{% endif %}

Here is the snippet where I entered the code. Please let me know if this helps or you need a larger snippet.

<span class="order-list__item-title">{{ line_title }}&nbsp;&times;&nbsp;{{ line_display }}</span><br/>

        {% if line.variant.title != 'Default Title' and is_parent == false %}
  <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
{% elsif line.variant.title != 'Default Title' and line.nested_line_parent? %}
  <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
{% elsif line.variant.title != 'Default Title' and line.bundle_parent? and false == false %}
  <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
{% endif %}

{% if line.sku != blank %}
  <p style="margin: 0; font-size: 14px; color: #555;">
    SKU: {{ line.sku }}
  </p>
{% endif %}


          {% if false %}
            {% for child_line in line.bundle_components %}

Thank you so much!

Ah, now it’s much clearer what’s happening. The issue here is why SKUs show in the email preview but not in actual test orders this usually happens because line.sku isn’t accessible in the customer-facing email context the same way it is in staff notifications.

Here’s a breakdown in simple terms:


Why it’s not showing

Staff vs. Customer emails

Staff order notifications have access to the full line object, including line.sku.

Customer-facing emails sometimes use a simplified line item object (line_title, line_display) and may not include line.sku by default.

Variables used in your snippet

You’re using line_title and line_display for the title and quantity — this is typical for customer emails.

line.sku may not exist in this context, so the {% if line.sku != blank %} block never runs in the actual order email.


How to fix

You have two main options:

Use the variant.sku via line.variant.sku

In customer emails, line.variant.sku is usually available even if line.sku isn’t. Replace your snippet with:

{% if line.variant.sku != blank %}
  <span class="order-list__item-sku" style="font-size:14px; color:#999;">
    SKU: {{ line.variant.sku }}
  </span><br/>
{% endif %}

Place it right below your product title block:

<span class="order-list__item-title">{{ line_title }}&nbsp;&times;&nbsp;{{ line_display }}</span><br/>

{% if line.variant.sku != blank %}
  <span class="order-list__item-sku" style="font-size:14px; color:#999;">
    SKU: {{ line.variant.sku }}
  </span><br/>
{% endif %}

{% if line.variant.title != 'Default Title' and is_parent == false %}
  <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
{% elsif line.variant.title != 'Default Title' and line.nested_line_parent? %}
  <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
{% elsif line.variant.title != 'Default Title' and line.bundle_parent? and false == false %}
  <span class="order-list__item-variant">{{ line.variant.title }}</span><br/>
{% endif %}

This usually fixes the problem and SKUs show in actual customer emails.


Optional: Add fallback for bundles

If you’re using bundles or nested products, you may also want to check child_line.variant.sku inside your bundle loop:

{% for child_line in line.bundle_components %}
  {% if child_line.variant.sku != blank %}
    <span style="font-size:14px; color:#999;">
      SKU: {{ child_line.variant.sku }}
    </span><br/>
  {% endif %}
{% endfor %}


If you want, I can rewrite your full order email snippet so it supports SKUs for all products, including bundles and variants, ready to paste into Dawn’s customer order email template.

@TheScriptFlow_1 Thank you for taking the time to respond and for your willingness to help. However, I’ve already tried getting assistance from ChatGPT on this matter, and it hasn’t resolved the issue. I’m really hoping for guidance from someone with experience in coding. Any insight on why the SKUs show in the preview but not in the actual customer emails would be greatly appreciated.