Add product metafield to html table

fro
Excursionist
12 1 1

Hello,

 

I am using the Dawn 2.0 theme. I have created page with a html table. I have also created a product metafield.

 

I would like to add this product metafield to one of the cells in this table. Is that possible?

 

<table width="100%">
<tbody>
<tr>
<td style="width: 35.0423%;">Test1</td>
<td style="width: 26.9577%;">Test2</td>
<td style="width: 31%;">Test3</td>
</tr>
<tr>
<td style="width: 35.0423%;">Case A</td>
<td style="width: 26.9577%;">8</td>
<td style="width: 31%;">2</td>
</tr>
<tr>
<td style="width: 35.0423%;">Case B</td>
<td style="width: 26.9577%;">3</td>
<td style="width: 31%;">2</td>
</tr>
<tr>
<td style="width: 35.0423%;">Case C</td>
<td style="width: 26.9577%;">5</td>
<td style="width: 31%;">4</td>
</tr>
</tbody>
</table>

 

Replies 4 (4)
LitExtension
Shopify Partner
3731 738 782

Hi @fro,

You can get Metafields directly and add to table. For example for Metafields is subtitle

Screenshot.png

You just need to add the following code where you want to display the Metafields, it will work fine:

{{ product.metafields.my_fields.subtitle }}

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Have not had your Shopify store yet? Start the 14-day free trial HERE
Are you looking for a solution to migrate to Shopify? Try our FREE DEMO now!
fro
Excursionist
12 1 1

Unfortunately, this does not seem to work.

I added a text metafield en copied the key/name to the html table in a new page.

Then I added the page as a dynamic source to the collapsible row on the product page.

 

fro_0-1652511606111.png

 

LitExtension
Shopify Partner
3731 738 782

Hi @fro,

With page content displayed at 'Collapsible content', it would be impossible.

Because page content doesn't support liquid code so if you want to add Metafield you need to create your own field and add code for it, instead of getting a content page.

Hope it is clear to you.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Have not had your Shopify store yet? Start the 14-day free trial HERE
Are you looking for a solution to migrate to Shopify? Try our FREE DEMO now!
MrL22
Shopify Partner
7 0 1

I was looking for a very similar thing to generate tables and ended up developing this free tool which can be implemented easily into your theme. https://webforward.github.io/shopify-tables/