Skip to content
Articles

Using metafields on labels

Add Shopify product and variant metafields to BarcodeMan labels, including custom text, images, namespaces, and keys.

Verified
On this page

Metafields store extra product information, such as material or care instructions. To print that information, create a field in Shopify, give it a value on a product, then link a BarcodeMan element to it.

A product metafield has one value shared by that product’s variants. Use a variant metafield when each variant needs its own value. Each field has a namespace and key, such as custom.material, which BarcodeMan uses to identify it.

Create a text field in Shopify

If the field already exists, skip to filling in its value.

  1. In Shopify admin, open Settings → Metafields and metaobjects and choose Products. Choose Variants for a field that belongs to individual variants.
  2. Click Add definition and name it Label material.
  3. Check Namespace and key. For this example, use custom.label_material if that key is available, or keep the generated key and use it throughout the steps below.
  4. Click Select type, choose Single line text, and keep One value.
  5. Click Save.

Older Shopify screens may call this settings section Custom data. Shopify also provides an Add definition action in a product’s Metafields section. See Shopify’s definition setup instructions.

Fill in the product’s value

  1. Open Products in Shopify admin and select a product. For a variant metafield, open the specific variant.
  2. Find Metafields and open Label material. If it is not displayed, click View all.
  3. Enter Cotton and click Save.

Repeat for other products or variants that need this field. Creating the definition does not fill in their values. See Shopify’s instructions for adding values.

How to add a metafield to your label

Which screen do you see?

Choose the description that matches your app to see its steps.

New interface

  1. Open your template and add or select a Text element.
  2. Set Link To to METAFIELD_PRODUCT or METAFIELD_VARIANT.
  3. Under Metafield → Enter namespace.key, open Available metafields… and select your definition, such as Label material (custom.label_material).
  4. Position the element, save the template, and generate a label for the product or variant you filled in. The example should print Cotton.

If the definitions fail to load, use Try again. An empty list after loading means you should check that definitions exist for the selected product or variant type.

Earlier interface

  1. Open your template and add or select a Text element.
  2. Set Link To to METAFIELD_PRODUCT or METAFIELD_VARIANT.
  3. Under Metafield → Enter namespace and key, type the complete key, such as custom.label_material.
  4. Position the element, save the template, and generate a label for the product or variant you filled in. The example should print Cotton.

Copy the namespace and key from your store’s metafield definition into the text input.

Displaying images from metafields

For an image URL, such as the address of a certification logo, create a separate field:

  1. Return to the product or variant metafield definitions in Shopify and click Add definition.
  2. Name it Label image and note its Namespace and key, for example custom.label_image.
  3. Under Select type, choose URL, keep One value, and click Save.
  4. Open the product or variant. In Metafields, fill Label image with a direct image URL and save. Use View all if the field is hidden.

The URL must open the image itself and be accessible without signing in. A product page URL will not work. Shopify’s File type stores a file reference, which is different from the URL field used in this example. See Shopify’s metafield types.

In BarcodeMan:

  1. Add an Image element to your template.
  2. Set Link To to METAFIELD_PRODUCT or METAFIELD_VARIANT, matching where you saved the URL.
  3. Select the definition in the new editor, or enter its namespace.key in the legacy editor.
  4. Save the template and generate a label for that product or variant.

If the image fails to load, follow Image does not show on label. A publicly accessible image can still have browser access restrictions.

Troubleshooting

Metafield shows blank on the label

Check the value on the exact product or variant you are printing. Then check that the element uses the matching product or variant source and the correct namespace.key. A field that exists but has no value will not supply text for the label.

Metafield list won’t load (new editor)

Use Try again if a loading error appears. If loading succeeds but the list is empty, confirm that the definition belongs to the selected product or variant type. Reopen the editor after creating a new definition if it has not appeared yet.

In the legacy editor, enter namespace.key manually; there is no definition list.

Wrong metafield value showing

Make sure you selected the correct metafield (check the namespace and key). Choose the matching product or variant source before selecting or entering the key.

Questions about this article? Email our team.

Send feedback