{%- assign nutrients_ordered = "calories,total-fat,saturated-fat,trans-fat,cholesterol,sodium,total-carbohydrates,fiber,total-sugars,added-sugars,protein,vitamin-d,calcium,iron,potassium" | split: "," -%}
{%- assign serving_data = "servings-per-container,serving-size-measure,serving-size-g" | split: "," -%}
{% assign prod_meta = product.metafields.nutrition %}
Nutrition Facts
{%- if prod_meta[serving_data[0]]-%}
{{ prod_meta[serving_data[0]] }} servings per container |
{%- endif -%}
{%- if prod_meta[serving_data[1]] or prod_meta[serving_data[2]] -%}
Serving size |
{{ prod_meta[serving_data[1]] }}
{%- if prod_meta[serving_data[2]] -%}
({{ prod_meta[serving_data[2]] }})
{%- endif -%} |
{%- endif -%}
Amount per serving |
{% for nutrient in nutrients_ordered %}
{%- if prod_meta[nutrient] -%}
{%- assign value = prod_meta[nutrient] -%}
{%- assign nutrient_meta = shop.metafields.nutrition[nutrient] -%}
{%- assign nutrient_words = nutrient | split: '-' -%}
{%- capture nutrient_title -%}
{%- for word in nutrient_words -%}
{{ word | capitalize }}
{%- endfor -%}
{%- endcapture -%}
{{ nutrient_title }} {{ value }}{{ nutrient_meta.units}} |
{%- if nutrient_meta.rdv -%}
{{ value | times: 100.0 | divided_by: nutrient_meta.rdv | round }}%
{%- else -%}
No RDV
{%- endif -%} |
{%- if forloop.first -%}% Daily Value |
{%- endif -%}
{%- endif -%}
{% endfor %}