To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more

Add product metafield to html table

fro
Excursionist
14 1 2

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
4801 982 1008

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 - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
fro
Excursionist
14 1 2

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
4801 982 1008

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 - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
MrL22
Shopify Partner
16 0 9

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/