Metafield Liquid generator

Add metafields to Shopify Order Printer

Build copy-paste Liquid snippets for product, variant, order, and customer metafields in Shopify Order Printer templates.

Quick answer

Add metafields to Shopify Order Printer for Shopify Order Printer

Choose the owner object, namespace, key, label, and fallback text before copying the Liquid block. Start in a duplicate Shopify Order Printer template, paste the Liquid in the right placement area, and preview with real orders before saving.

  1. Confirm the metafield namespace and key in Shopify admin.
  2. Check whether the field is stored on the order, customer, product, or variant before choosing the snippet.
  3. Choose the owner object: order, customer, product, or variant.

Copy-ready example

Starter Liquid pattern

Use this as a visible pattern, then use the generator below to adjust the exact field, fallback text, layout, and test notes.

{% for line_item in line_items %}
  {% assign opk_value = line_item.product.metafields.custom.your_key.value %}
  {% if opk_value != blank %}
    <p><strong>Product detail:</strong> {{ opk_value }}</p>
  {% endif %}
{% endfor %}

Metafield Liquid generator

Add metafields to Shopify Order Printer

Choose the owner object, namespace, key, label, and fallback text before copying the Liquid block.

Standard order with one clear product row.
Need a blank product metafield row fixed?

Product and variant metafields usually print blank when they are outside the item loop or stored on the other owner object.

Fix blank metafield output

Paid feature signals

Generated Liquid

Copy-paste code

{% for line_item in line_items %}
  {% assign opk_metafield = line_item.product.metafields.custom.country_of_origin.value %}
  {% if opk_metafield != blank %}
    <p class="opk-line-metafield">
      <strong>Country of origin:</strong> {{ opk_metafield }}
    </p>
  {% else %}
    <p class="opk-line-metafield opk-muted">
      <strong>Country of origin:</strong> Not provided
    </p>
  {% endif %}
{% endfor %}

Install wizard

Place the snippet before testing output.

1
Template area

Line item loop

2
Paste target

Paste inside the line item loop so each product can read its own metafield.

3
Test order

Order whose selected owner has this metafield filled in

Paste location

Paste inside the line item loop so each product can read its own metafield.

Test checklist

  • Duplicate the Shopify Order Printer template before editing the live one.
  • Preview with the regular order.
  • Use an order whose product, variant, customer, or order data has the field filled in.
  • Print or save one test preview before using the template in production.

Common failure

  • The namespace or key is copied incorrectly from Shopify admin.
  • A product or variant metafield is pasted outside the line item loop.
  • An order metafield path is used for data that is stored on the product or variant.

Mock preview

#1048Standard order with one clear product row.

Country of origin: United States

Use case

When to use this tool

Best for merchants adding product specs, HS codes, country of origin, VAT notes, wholesale fields, or customer fields to printed documents.

Supports order, customer, product, and variant metafield paths.

Explains when product and variant metafields must stay inside the line item loop.

Shows how to choose the owner object based on where the data is stored, not where it should appear on the printout.

Covers common field examples: HS code, country of origin, bin location, product care notes, VAT ID, and B2B customer data.

Adds fallback text so blank metafields do not break the document.

Uses .value paths for modern metafield output when the direct value is available.

Connects metafield placement to common invoice, packing slip, VAT, and customs use cases.

Free tool fit

Use the snippet when the edit is narrow.

Choose the owner object, namespace, key, label, and fallback text before copying the Liquid block.

  • You know which Shopify Order Printer template you want to edit.
  • You can test in a duplicate template before touching the live one.
  • The field or layout change maps to the Liquid objects listed on this page.

Manual fix fit

Request help when placement is risky.

Get the snippet merged into your existing invoice or packing slip template.

  • Your current template already has custom loops, tables, CSS, or app-specific fields.
  • The snippet works in isolation but prints blank, repeats, or breaks layout in your real template.
  • The document is customer-facing, B2B, VAT, customs, or warehouse-critical and needs careful test notes.

Install steps

Copy into Shopify Order Printer carefully.

The preview uses sample data. Always test the template with real orders before using it for fulfillment, accounting, customs, or customer-facing documents.

  1. Step Confirm the metafield namespace and key in Shopify admin.
  2. Step Check whether the field is stored on the order, customer, product, or variant before choosing the snippet.
  3. Step Choose the owner object: order, customer, product, or variant.
  4. Step Use product metafields for values shared by all variants, and variant metafields when size, color, barcode, HS code, or origin can change by variant.
  5. Step Paste order and customer metafields near order details, billing details, or customer sections.
  6. Step Paste product and variant metafields inside the line item loop near item title, SKU, quantity, or customs columns.
  7. Step Preview with an order whose product, variant, customer, or order actually has that metafield populated.

Problem diagnosis

Match the symptom before changing Liquid.

Use these checks to decide whether the issue is field data, snippet placement, print settings, or a template merge problem.

The metafield prints fallback text.

Likely cause
The namespace/key is wrong, the field is empty on the selected order, or the owner object does not match where the value is stored.
Fix
Copy the machine-readable namespace and key from Shopify admin, then test with product, variant, order, or customer data that actually has a value.

Product or variant metafields do not print.

Likely cause
The snippet was placed in the document header or footer, where line_item.product and line_item.variant are not available.
Fix
Paste product and variant metafields inside the line item loop near title, SKU, quantity, customs columns, or item notes.

The value is correct for one variant but wrong for another.

Likely cause
A product metafield is being used for data that changes by variant, such as HS code, origin, size-specific material, or barcode.
Fix
Store variant-specific values on the variant and switch the snippet to line_item.variant.metafields.namespace.key.value.

The same value repeats for every item row.

Likely cause
The snippet is reading an order or product-level field when the merchant expects variant-specific or item-specific data.
Fix
Confirm whether the source should be order, customer, product, or variant, then use variant metafields for values that change by purchased variant.

A complex object prints as unreadable text.

Likely cause
The metafield is a list, reference, or metaobject instead of a simple text or single-line value.
Fix
Use this generator for direct values first; request a manual code fix for metaobject references or list formatting.

FAQ

Common Shopify Order Printer issues

What is the correct metafield path format?

Shopify Order Printer commonly uses object.metafields.namespace.key.value, such as order.metafields.shipping.express_delivery_status.value.

Where do I find the namespace and key?

Open the metafield definition in Shopify admin and copy the namespace and key values, not just the display name shown to staff.

How do I know which owner object to choose?

Use order for order-level notes, customer for customer or B2B data, product for fields shared by all variants, and variant when the value changes by variant.

Where should product metafields go?

Product and variant metafields usually belong inside the line item loop, near product title, SKU, quantity, or barcode.

What is the variant metafield path?

Use line_item.variant.metafields.namespace.key.value inside the line item loop, replacing namespace and key with the values from Shopify admin.

Why does the fallback text print?

The path may be wrong, or the test order may not have that metafield populated on the selected product, variant, customer, or order.

Can this handle metaobjects?

The first version focuses on direct metafield values. Complex references and metaobjects should be handled as a paid code fix.

Related exact fixes

Follow the next likely Order Printer problem.

These links connect adjacent search intents, such as blank metafields, item-level customs fields, B2B invoice data, and one-off template fixes.

Packing slip metafield

Add a metafield to a Shopify packing slip

Best for merchants adding HS codes, country of origin, pick notes, wholesale fields, or product specs to warehouse documents.

Open related fix

Commercial invoice fields

Shopify commercial invoice template for Order Printer

Best for cross-border merchants preparing document templates that need item-level customs data in a printable layout.

Open related fix

HS code Order Printer

Add HS codes to Shopify Order Printer

Best for cross-border merchants who need an HS code column on a commercial invoice, customs packing slip, or export document built in Shopify Order Printer.

Open related fix

Country of origin invoice

Add country of origin to a Shopify invoice

Best for merchants whose commercial invoice or customs document needs origin printed per line item, especially when variants can have different origins.

Open related fix

Barcode snippet generator

Add a barcode to a Shopify packing slip

Best for merchants who need a scannable order number, SKU, variant barcode, or tracking number on a packing slip without installing a full PDF invoice app.

Open related fix

Line item properties

Show Shopify line item properties in Order Printer

Best for merchants whose product options, personalization notes, bundle details, or gift messages are stored as line item properties instead of metafields.

Open related fix

VAT invoice fields

Shopify VAT invoice template fields

Add VAT IDs, tax notes, and B2B invoice fields with cautious scope.

Open related fix

PO number invoice

add a PO number to Shopify invoices

Handle B2B purchase order data without repeating it inside item rows.

Open related fix

Common Order Printer fixes

Keep editing the same Shopify template.

These are the highest-signal internal paths for merchants who need template code, packing slip layout, barcodes, metafields, or 4x6 print fixes.

Template code generator

free Shopify Order Printer template code generator

Start with a printable template before adding fields.

Open tool

Packing slip template code

Shopify packing slip template code

Build the base pick-pack document for warehouse use.

Open tool

Barcode snippet generator

add a barcode to a Shopify packing slip

Print order, SKU, variant, tracking, or QR codes.

Open tool

4x6 packing slip starter

Shopify 4x6 packing slip template

Test thermal printer layout, margins, and item overflow.

Open tool

Line item properties

Shopify Order Printer line item properties

Show personalization, bundle details, and gift options.

Open tool

Liquid objects

Fields this page usually touches

  • order.metafields.namespace.key.value
  • customer.metafields.namespace.key.value
  • line_item.product.metafields.namespace.key.value
  • line_item.variant.metafields.namespace.key.value
  • line_item.product.metafields.custom.hs_code.value
  • line_item.variant.metafields.custom.country_of_origin.value

Common errors

Watch these before saving

  • The namespace or key is copied incorrectly from Shopify admin.
  • A product or variant metafield is pasted outside the line item loop.
  • An order metafield path is used for data that is stored on the product or variant.
  • A product metafield path is used even though the value changes per variant.
  • A namespace/key label from the admin UI is copied instead of the machine-readable namespace and key.
  • A complex list, metaobject, or reference metafield needs formatting before it can print cleanly.
  • The test order uses products, variants, customers, or orders that do not have the metafield filled in.

Limits

What this does not replace

  • Direct metafield values are the safest first version.
  • Metaobject references, lists, and complex formatting usually need manual review.
  • Fields created by third-party product option apps may be line item properties instead of metafields.
  • The generator does not verify that your namespace/key exists inside Shopify.
  • Tax, customs, and compliance fields should be checked by the merchant before production use.