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. Use the machine-readable namespace and key, not the admin display label shown to staff.

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 %}

Blank metafield diagnosis

Fix blank Shopify Order Printer metafields before changing the whole template.

Most blank metafields come from the wrong owner object, a display label used as the namespace/key, missing test-order data, or product/variant code outside the line item loop.

Symptom Check first Fix
Fallback text prints instead of the metafield value Confirm the Shopify admin namespace and key, not the display label shown to staff. Use object.metafields.namespace.key.value and test with an order that has the field populated.
Product or variant metafield is blank Check whether the snippet is inside the line item loop and whether the value belongs to product or variant. Use line_item.product.metafields... for product data or line_item.variant.metafields... for variant data.
Customer or order metafield repeats on every item row Look for order-level or customer-level code pasted inside the item table loop. Move order and customer metafields to the order details, billing, or customer section.
Shopify admin shows a value but Order Printer does not Verify owner object, test order data, namespace/key spelling, and whether the metafield requires .value. Preview a real order with the matching product, variant, customer, or order metafield before saving.

Free first, fix when needed

Use the generator for the first safe test.

Choose the owner object, namespace, key, label, and fallback text before copying the Liquid block. If the snippet works alone but your real Shopify Order Printer template has custom loops, tables, print CSS, app fields, or compliance-sensitive wording, send the current template for a scoped fix.

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

Need more than code snippets?

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.

Gives a blank-output checklist for owner object, namespace/key, line item placement, and direct .value output.

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 Use the machine-readable namespace and key, not the admin display label shown to staff.
  4. Step Choose the owner object: order, customer, product, or variant.
  5. 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.
  6. Step Paste order and customer metafields near order details, billing details, or customer sections.
  7. Step Paste product and variant metafields inside the line item loop near item title, SKU, quantity, or customs columns.
  8. Step If fallback text prints, check owner object, namespace/key spelling, whether the test order contains that product or customer, and whether the metafield needs .value.
  9. 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.

The metafield is filled in Shopify admin but prints blank.

Likely cause
The preview order may not contain the product, variant, customer, or order where the value is stored, or the snippet is reading product when the value lives on variant.
Fix
Open the exact test order and match the field owner first. Use line_item.product for product data, line_item.variant for variant data, customer for customer data, and order for order data.

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.

Why is my metafield blank even when Shopify admin shows a value?

Usually the code is reading the wrong owner object, the test order does not contain that product or customer, the namespace/key is the display label instead of the machine key, or a product/variant path was pasted outside the line item loop.

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 product metafields to a Shopify packing slip

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

Add product metafields to a Shopify packing slip

Commercial invoice fields

Shopify commercial invoice template with HS code and origin

Best for cross-border merchants preparing Shopify invoice or commercial invoice templates that need item-level HS/HSN code, origin, and customs data in a printable layout.

Shopify commercial invoice template with HS code and origin

HS code Order Printer

Add HSN or HS code to Shopify invoices

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

Add HSN or HS code to Shopify invoices

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.

Add country of origin to a Shopify invoice

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 or bulk barcode label app.

Add a barcode to a Shopify packing slip

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.

Show Shopify line item properties in Order Printer

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.

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.
  • The snippet omits .value and prints an object-like value instead of the readable field content.
  • 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.