It seems like I’m doing double work here. Ideally, I would like to insert some coding in product description section so that I only need to fill in metafield and product description table will generate automatically.
a. Logic should be: 1.Create a table. If product attribute A is blank, then not show up in desciption table, otherwise show product attribute A & its value. Then product attribute B, C, D,…etc.
b. I’d like to format the table size, key length,value length with some CSS formating.
Ideally, I’d like the table formatting look like this:
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/
What I wanted to avoid was that if I needed to change the styling or layout of the table, I did not want to be editing all of my products again.
I have just tried this again on a new store I am working on and it is working. Can you try changing {{ row.0 }} to {{ row.1 }} and let me know what happens?
That is very odd. I wonder what is different in your set up. Defintely set the field to type of JSON?
Can you try this?
{% if product.metafields.namespace.metakey.value.size > 0 %}
{% for row in product.metafields.namespace.metakey.value %}
{% if row.size == 1 %}
{% for col in row %}
{% endfor %}
{% else %}
{% for col in row %}
{% endfor %}
{% endif %}
{% endfor %}
| {{ col | last }} | {{ col | last }} |
| - | - |
{% endif %}