Print Metafields on a Shopify Packing Slip
The packing slip lists the jacket. It does not say the jacket takes two weeks to arrive. That detail lives in a metafield on the variant, and the person packing the box never sees it.
Put it on the slip. A packing slip template can read your product and variant metafields, the same way a Shopify theme does. Paste a few lines, save, done.
Table of Contents
- What You Can Read
- Add It to the Template
- Variant First, Product as Fallback
- Numbers, True or False, and Lists
- The Preview Shows a Sample
- Need Help?
What You Can Read
Inside the line item loop of the packing slip template, each item has two new things:
item.variant.metafields.<namespace>.<key>for a metafield on the variant.item.product.metafields.<namespace>.<key>for a metafield on the product.
The namespace and key are the ones Shopify shows under Settings, then Custom data. A metafield called custom.lead_time is item.variant.metafields.custom.lead_time.
Nothing changes in what AutoPrintEmail can access. It still only reads your store.
Add It to the Template
- In the AutoPrintEmail app, open Templates and pick Order packing slip.
- Switch to Code.
- Find the line item loop. It starts with
{% for item in order.lineItems %}. - Paste this where the text should appear, for example under the item title:
- Change
custom.lead_timeto your own namespace and key. - Click Save and print a sample.
Variant First, Product as Fallback
Some shops set the value on the product and only override it on a few variants. This prints the variant's value when there is one, and the product's when there is not:
Numbers, True or False, and Lists
Printed on its own, a metafield gives its text. Add .value when you need the real type:
- A number you want to do maths with:
{{ item.variant.metafields.custom.days.value | plus: 1 }} - A true or false:
{% if item.product.metafields.custom.fragile.value %}FRAGILE{% endif %} - A list:
{{ item.product.metafields.custom.materials.value | join: ", " }}
The Preview Shows a Sample
The preview and the sample print use a made-up order, so there is no real product behind them. A metafield shows as a stand-in such as "Sample lead time". That is there so you can see where it lands on the page.
Real orders print the real value.
Need Help?
It prints blank on a real order? Check these in order:
- The namespace and key match Shopify exactly.
lead_timeandleadtimeare different keys. - The metafield is on the right thing. A value saved on the product is read with
item.product, notitem.variant. - That variant actually has a value. An empty metafield prints nothing, which is what the
!= blankcheck is for. - The line is a real product. A custom line added by hand to an order has no variant, so it has no metafields.
Still stuck? Message us with the order number and the metafield name and we will look at it with you.