Thanks for sharing your code here, this solution worked great for me. (also using a Turbo theme). One issue i’m trying to sort out is some variants of a product do not have data for a metafield (e.g. I’m using this to display backorder Shipping dates). Do you have any pointers on how i could modify this to not display anything for products that have data in the metafield? Since variant.sku is the filter all variants load the code to display the metafield data.
In my case it is something like this in the product template:
{% capture 'meta_data' %}
{% for variant in product.variants %}
{{ variant.sku | json }}: {{ variant.metafields.my_fields.delivery_month | json }}
{% unless forloop.last %},{% endunless %}
{% endfor %}
{% endcapture %}
{% if variant.sku != blank %}
Ships by: {{ variant.sku }}
{% endif %}
and then using this in my sections.js.liquid
$('.backorder span', $product).text(metaData[variant.sku]);