Automation guide

How to show a product metafield on a badge in Shopify

Quick answer

To show a product metafield on a Shopify badge, create a product metafield in the custom namespace (for example custom.warranty), fill in the value on each product, then add {{mtf.warranty}} to the Label Text of a text label in Nexora Product Labels & Badges. Each product's badge shows its own value, such as 2-year warranty. To show a badge only on products whose metafield has a value, use the Product metafield condition under Products matching conditions.

Updated 8 min read Install free

Why put metafield data on a badge

Metafields hold the product facts that Shopify has no standard field for: warranty length, country of origin, material, roast level, battery life, pages, ABV. Shoppers often care about these details more than the product description, but they are usually buried far down the product page.

A badge brings one key fact up to the product image or right next to the title, on collection pages as well as product pages. Because the value comes from the metafield, you edit it in one place and every badge follows.

  • {{mtf.warranty}} warranty → 2-year warranty
  • Made in {{mtf.origin}} → Made in Portugal
  • {{mtf.roast}} roast → Medium roast
  • {{mtf.material}} → 100% linen

Metafield badges also suit facts that differ between products but follow one pattern. Instead of writing ten labels (1-year warranty, 2-year warranty and so on), you write one label with {{mtf.warranty}} warranty and let each product fill in its own value. Changing a warranty later is a single edit on the product.

Your options on Shopify

In Online Store 2.0 themes you can connect a metafield to a theme block through dynamic sources in the theme editor. That's great for product pages, but most themes don't offer a block on product cards in collection grids, and the styling depends on the block. See Shopify's guide to creating custom metafield definitions.

OptionProduct pageCollection cardsEffort
Theme block with a dynamic sourceYes, if your theme has a suitable blockRarelyLow
Custom Liquid codeYesYesNeeds a developer
A text label with {{mtf.KEY}}YesYesLow

Step by step: a metafield badge

Metafield variables such as {{mtf.warranty}}, and metafield conditions, are part of the Pro plan ($6.99 every 30 days or $59 a year, with a 7-day free trial).

  1. Create the metafield definition

    In your Shopify admin, go to Settings > Metafields and metaobjects > Products and add a definition. Use the custom namespace, a key with letters, numbers and underscores (for example warranty), and a simple type such as single line text or a number.

  2. Allow storefront access

    In the definition's access options, make sure Storefronts is selected. The app reads the value on your storefront, so it needs this access.

  3. Fill in the values

    Open each product and enter the value in the Metafields section, for example 2-year.

  4. Create a text label

    In the app, click + Add Label. On General, choose the Text type and a shape, and pick Inside Product Image or In Product Info Area.

  5. Add the variable

    On Design, set Label Text to {{mtf.warranty}} warranty. The part after mtf. must match your metafield key exactly.

  6. Choose products, activate and save

    On Display condition, set Products to the products, collections, tags or vendors that have the metafield, or to Products matching conditions with a Product metafield rule. Click Activate, then Save.

A text label whose Label Text uses {{mtf.warranty}}

What works and what to watch

DetailWhat to know
NamespaceOnly custom. {{mtf.warranty}} reads custom.warranty
Key formatLetters, numbers and underscores, matching the key exactly
Best typesSingle line text, integer and decimal show cleanly
Other typesLists, references and measurement types are shown as their raw stored value, which may not read well
Empty valueWith Hide the label when a variable has no value ticked (default for new labels), the label is hidden on that product. Unticked, the variable is left empty and the rest of your text still shows
Where it showsProduct images and cards on product, collection, search and home pages

If Hide the label when a variable has no value is unticked, {{mtf.warranty}} warranty reads just warranty on a product without a value. Keep the option ticked, or limit the label to products that have the metafield with Products > Products matching conditions > Product metafield custom.warranty has a value.

Showing a badge based on a metafield

{{mtf.KEY}} prints a value. Sometimes you don't want to print it, only to decide which products get a badge: a Vegan badge on products whose custom.diet is vegan, or a 2-year warranty image on products where a warranty metafield has a value. For that, use a condition instead of a variable.

  1. Choose Products matching conditions

    On Display condition, set Products to Products matching conditions. This is available on manual labels.

  2. Add a Product metafield rule

    Pick Product metafield, then choose a definition or type namespace.key. Operators are has a value, is empty, is equal to, is not equal to and contains.

  3. Combine if needed

    Add more rules, such as Collection is in Coffee, and choose All conditions or Any condition.

  4. Save and wait a moment

    After you save, the app works out which products match. That can take up to a few minutes for large stores, and the list is kept up to date as products change.

{{mtf.KEY}} variableProduct metafield condition
What it doesPrints the value in the label textDecides which products show the label
Namespacescustom onlyAny namespace, including other apps'
Storefront accessNeededNot needed
Label typesText and Stock barAll, on manual labels

If a metafield condition matches a very large number of products, the editor may ask you to narrow it, for example by adding a collection rule.

Choosing the right metafield type

The badge shows the stored value exactly, so pick a type whose value already reads well on its own:

Product factMetafield typeLabel TextShows
Warranty lengthInteger, key warranty_years{{mtf.warranty_years}}-year warranty2-year warranty
MaterialSingle line text, key material{{mtf.material}}Organic cotton
Battery lifeInteger, key battery_hours{{mtf.battery_hours}}h battery30h battery
Alcohol contentDecimal, key abv{{mtf.abv}}% ABV5.5% ABV
A yes/no fact, such as veganBetter as a product tagVegan as static text, with Products > Product tags = veganVegan

A true or false metafield would show the word true on the badge, which is why yes/no facts work better as a tag with fixed text. Lists, measurements and references also show their raw stored value, so use single line text when you want full control over the wording.

Example: origin and roast for a coffee shop

A coffee roaster stores custom.origin (single line text) and custom.roast (single line text) on every bag.

  • Label 1: In Product Info Area, Above title, {{mtf.origin}}, small uppercase grey text. Shows ETHIOPIA, COLOMBIA and so on above each product name.
  • Label 2: Inside Product Image, Bottom-Left, a pill shape with {{mtf.roast}} roast, background colour matched to the brand.
  • Both labels use Products → Collections → Coffee, so merchandise like mugs never shows an empty badge.
A metafield value shown above the product title

Second example: two specs on one electronics badge

A headphone store keeps custom.battery_hours and custom.warranty_years (both integers) on every pair. One text label can use both variables:

  • Label Text: {{mtf.battery_hours}}h battery · {{mtf.warranty_years}}-yr warranty, which shows 30h battery · 2-yr warranty
  • In Product Info Area, Below price, aligned Left, so the specs sit under the price on cards and product pages
  • Products > Collections = Headphones, so cables and cases without these metafields never show a half-empty badge
Choose where the metafield badge sits: on the image or in the product info area

The values come from the product, not the variant, so the badge stays the same when a shopper picks a different colour.

Troubleshooting metafield badges

  • Badge shows only the static text. Check the key spelling, that the namespace is custom, that the product has a value, and that the definition allows Storefronts access.
  • Value looks like code. You're probably using a list or reference type. Use a single line text metafield for the badge.
  • Key has a hyphen. The variable only reads keys made of letters, numbers and underscores. A key like care-guide won't be picked up; create the metafield as care_guide instead.
  • Spaces and case. {{ mtf.origin }} with spaces inside the braces works, but the key must match the metafield key exactly, including upper and lower case.
  • Different language stores. You can write a translation of the surrounding text per language, for example Garantie {{mtf.warranty}} in French.
  • Need help? Message us on live chat in the app, or email [email protected].

Frequently asked questions

Which metafields can a badge show?

Product metafields in the custom namespace, using {{mtf.KEY}}. For example, {{mtf.material}} shows custom.material.

Can I use a metafield from another app's namespace?

Not as text: the {{mtf.KEY}} variable reads the custom namespace only, so copy the value into a custom metafield if you need to print it. For deciding which products get a badge, the Product metafield condition works with any namespace.

Why is my metafield badge blank?

Usually the product has no value, the key doesn't match exactly, or the definition doesn't allow Storefronts access.

Can I use a metafield in an image label?

Not as a variable: variables only work in Text labels and the text of Stock bar labels. You can still show an image label only on products with a certain metafield value, using the Product metafield condition.

Can a badge show a variant metafield?

No. {{mtf.KEY}} reads product metafields only, so the value stays the same for every variant of the product.

Does it work on collection pages?

Yes. Metafield badges show on product cards as well as product pages.

Keep reading

Related guides

Get started with Nexora Product Labels & Badges

Start on the free plan and upgrade only when you need more. Billing runs through Shopify.