FROM CACHE - en_header

Variant Metafields & Order Printer App

Shopify Partner
6 0 2

Hi All,

I'm doing some work for a client, and working on customizing the template for the Order Printer app to include some additional information. 

They use metafields on the variant object to include this info, and the following code works fine on the cart page to display the information (inside the cart line item loop):

{% if item.variant.metafields.variant-fields.variant_skus != blank %}
  <span>Includes: {{ item.variant.metafields.variant-fields.variant_skus }}</span>
{% endif %}

However, the same code in the order printer template file doesn't produce any output. 

Thanks in advance,


Replies 3 (3)
Shopify Partner
118 0 51

Hi Cameron, 

Order printer doesn't have access to metafields, of any kind.


★Shopify tweaker★
Shopify Partner
6 0 2

Hi Jordy,

Thanks for your response. 

Sadly this does appear to be the case, though I haven't found any documentation to this effect.


Shopify Partner
6 0 1

Here's a workaround. As usual, in Shopify you need to get creative 🙂


You can add cart attribute and then print it on the Print order.

So what I came up with is to a hidden field that will capture the attribute, and we will send metafield value to that att then print it on Print Order.
_{{}}  is there in the attribute  name so we can have a dynamic attribute cause it needs to be unique to the cart item printed.

Step 1:
On the cart page, add this right below, for example, cart item title (if you wanna see it, remove "hidden"):




<input id="recipe" name="attributes[recipe_{{}}]"  value="{{item.variant.metafields.settings.variant_recipe}}" hidden></input>




Step 2:
Then on the print order template use this right below line item Title (where you see Product variant showing in the order):




{% capture lineItemID %}{{ }}{% endcapture %}

{% for a in attributes %}
{% assign a_internal = a.first | slice: 0 %}
{% if a.first contains "recipe" and a.first contains lineItemID and a.last != blank %}
<p>Recipe: {{ a.last }}</p>
{% endif %}
{% endfor %}




First we capture the cart item id, then loop through all the attributes, break name and value (those are first and last you see in the code) to get the attribute name, and show only the one with the "recipe" in the name and with current line item id.

We print the value only of that att we need.








Get in touch for more help.
Every pixel counts!