Shopify notifications and storefront theme
Last updated
Last updated
Let's assume your customer purchased a few trackable products from you. During the fulfilment process (e.g. order picking), you've added the serial numbers (or are using the unique item IDs provided by the app) and/or warranty duration/expiry. You would like to share this information with the customer when the items have been delivered or are in the progress of being delivered.
Since sold items of trackable ("track items" enabled) product variants are stored in order , the information is accessible in other parts of Shopify. This guide will show you how to share item information via the "Shipping confirmation" email notification; learn more about . However, the same principle applies to embedding metafields into other email or SMS notifications, your website's theme, and other apps supporting customisable templates with order metafields.
It's recommended to run through this guide on a test store first.
Open the "Shipping confirmation" email notification in Shopify admin settings (Settings > Notifications > Shipping confirmation). In there, you should see the markup for the email body. Let's add some markup to display serial numbers and warranty information under each tracked line item.
In the email body, you should notice
or similar (if you are not using the default template). This is our starting block. It loops through each line item and displays information about it.
Let's add some markup for the tracked lines under the product variant's title. You should see a code block that looks similar to the following:
Let's put the following code block right under:
The above snippet pulls the tracked items from the order metafields. If any serial numbers are populated for the line, it displays the "Serial number(s): " label and the serial numbers separated by a comma. It also displays the warranty duration for the line item if the value is set. It assumes that every tracked item uses the same warranty period and therefore picks the first one. Still, you could show the warranty durations of every item individually by looping through the tracked_line_items
array.
Unfortunately, the fake order in the preview is not serialized. Therefore, you would not be able to preview serial numbers or any other item information. To test the edited template, you need to serialize a test order and send a dummy notification.
If you're editing notification templates outside the "Shipping" section (e.g. "Order invoice"), you may need to replace the line.line_item.id
with line.id
. The variable line
represents the shipping line in shipping notifications and the line item in other order notifications.
If you wish to display unique item IDs provided by the app, replace all "serialNumber"
with "itemId"
in the snippet above, e.g.
To access serialized order items in other parts of Shopify (e.g. when ), you may need to add .value
after the metafield's key, i.e. replace order.metafields.serializer.properties.items
with order.metafields.serializer.properties.value.items
.
While the app only stores warranty duration, your liquid code could calculate an expiry date based on an order or shipping date (i.e. add duration to the date) using , e.g.