I’m trying to display the SKU of a product on the order confirmation page. I would want to have it located below the product.
Also, how can I accomplish this for the order confirmation email?
What script would I have to run for this to work for the order confirm page?
@mokumprix
For order confirmation email you need to add below code in order confirmation template.
Go to settings > Notifications > Order confirmation.
{% if line.quantity < line.quantity %}
{% capture line_display %} {{ line.quantity }} of {{ line.quantity }} {% endcapture %}
{% else %}
{% assign line_display = line.quantity %}
{% endif %}
{% capture variant_sku %} {{ line.variant.sku }} {% endcapture %}
{{ line_title }} × {{ line_display }}
SKU# {{ variant_sku }}
1 Like
Unfortunately, that did not work
This worked for me. You have to add the code that is mentioned above by going to settings>Notifications>Order Confirmation>Edit Code then you need to find the code as shown above and here below:
{% if line.quantity < line.quantity %} {% capture line_display %} {{ line.quantity }} of {{ line.quantity }} {% endcapture %} {% else %} {% assign line_display = line.quantity %}
{% endif %}
HERE IS WHERE YOU PASTE THIS PART:
{% capture variant_sku %} {{ line.variant.sku }} {% endcapture %}
THEN YOU NEED TO MAKE SURE YOU ADD THIS IN THE CODE BELOW (It will be missing when you pull it up):
SKU# {{ variant_sku }}
{{ line_title }} × {{ line_display }}
SKU# {{ variant_sku }}
Hopefully, that helps! It worked for me!
1 Like
@Isaiah_Vasquez this was very helpful, however this code shows the SKU under the item title but above the variant title (size, etc), if it exists.
It still works but to me the code visually splits the item so I modified it to put the SKU under the variant title
{% if line.variant.title != 'Default Title' %}
<span class="order-list__item-variant">{{ line.variant.title }} <br/>SKU# {{ variant_sku }}</span><br/>
{% endif %}
This layout looks better to me so the code above is for those who prefer it