Shopify Tutorials

How to Show Custom Data on Product Page using Metafield in Shopify

Hello Shopify Friends,

In this Shopify blog, we will learn How to Show Custom Data on Product Page using Metafield in Shopify.

Metafields in Shopify allow you to add custom fields to your products, allowing you to store and display additional information beyond the default product attributes in Shopify. Metafields allow you to display specialized information differently within your Shopify online store.

Let us learn how you can show custom data to a product page using Metafield in Shopify.

Steps to Show Custom Data on Product Page using Metafield in Shopify:

Step 1: Go to your Shopify admin, and in Shopify admin, click on Settings.

Step 2: After that, click on Custom data and go to Products metafield.

Step 3: Now click on Add definition.

Step 4: Fill up the name of metafield and select the type you want to add. Also, add a description if you want.

Step 5: After selecting the type of metafield, click on Storefronts to show that data in the online store, then Save it.

Step 6: Open any product on your admin, fill up the Metafields option, and Save it.

This is your namespace and key to show data on the product page.

Step 7: Click on the Online store, click Edit code, and search your main product page to add code.

Step 8: Add the below code in your product page 

{% if product.metafields.custom.custom_text.value  %}
     <p> {{ product.metafields.custom.custom_text.value }} </p>
{% endif %}

Step 9:  Now your output looks like the below screenshot

Conclusion:

By following these steps, you can create and utilize metafields to store and display custom data for your products in Shopify.

Related Article – How To Add Products To Shopify?

Share this tutorial to display custom data on the product page using Metafield in Shopify. Stay updated with us for more articles.

Happy Reading!

Click to rate this post!
[Total: 3 Average: 5]
Bharat Desai

Bharat Desai is a Co-Founder at MageComp. He is an Adobe Magento Certified Frontend Developer 🏅 with having 8+ Years of experience and has developed 150+ Magento 2 Products with MageComp. He has an unquenchable thirst to learn new things. On off days you can find him playing the game of Chess ♟️ or Cricket 🏏.

View Comments

    • Yes, you can do with printing the namespace of the metafield and its value like below

      {% assign product_metafields = product.metafields %}
      {% if product_metafields.size > 0 %}

        {% for metafield in product_metafields %}
      • Namespace: {{ metafield.namespace }}
        Value: {{ metafield.value }}
      • {% endfor %}

      {% else %}

      No metafields found for this product.

      {% endif %}

      {{ metafield.namespace }} will display the namespace of the metafield.
      {{ metafield.value }} will display the value of the metafield.

Recent Posts

Mastering Tailwind CSS in Laravel: A Comprehensive Guide

Tailwind CSS has emerged as a powerful utility-first CSS framework, offering developers a unique approach…

19 hours ago

React Native or Flutter in 2024

The mobile app development field has witnessed a rapid revolution over the past few years.…

3 days ago

Magento 2: How To Call JS on the Checkout Page?

Hello Magento mates, Today we will learn to add a call JS on the checkout…

6 days ago

Boost Your SEM Game: Unveiling the Top 10 Tools for Marketers in 2024

Business survival in today’s digital world has become extremely difficult. Using traditional marketing techniques is…

7 days ago

Five Essential Payroll Compliance Tips for eCommerce Startups

Are you setting up a payroll system for your eCommerce startup? Ensuring compliance with myriad…

1 week ago

Optimizing Laravel Blade: Unlocking Advanced Fetcher Techniques

In the expansive universe of Laravel development, Blade serves as the stellar templating engine, propelling…

1 week ago