Shopify themes, liquid, logos, and UX
Hi, I'm trying to create a nutrient value table that automatically calculates the nutrient reference values in %. When I add the code, it shows me the following liquid syntax error:
"Expected dotdot but found pipe in "{{ (product.metafields.custom.energie | divided_by: energie_ref | times: 100) | round: 2 }}"
Can anyone make sense of this? Thanks in advance for the help!!
Here's a part of the full code I'm trying to add, just in case this might be useful for troubleshooting:
{% assign energie_ref = 2000 %}
{% if product.metafields.custom.energie %}
{% assign has_nutrition_info = true %}
<tr>
<td>Energie</td>
<td>{{ product.metafields.custom.energie }} kcal</td>
<td>{{ (product.metafields.custom.energie | divided_by: energie_ref | times: 100) | round: 2 }}%</td>
</tr>
{% endif %}
Solved! Go to the solution
This is an accepted solution.
Hi @fm_vlv
In Liquid, you don't need to use parentheses to group operations - the filters are applied from left to right.
Please try the following code instead.
{{ product.metafields.custom.energie | divided_by: energie_ref | times: 100 | round: 2 }}
or you can even break it down as follows.
{% capture result %}
{{ product.metafields.custom.energie | divided_by: energie_ref | times: 100 }}
{% endcapture %}
{{ result | round: 2 }}
Let me know if it helps.
Thank you.
This is an accepted solution.
Hi @fm_vlv
In Liquid, you don't need to use parentheses to group operations - the filters are applied from left to right.
Please try the following code instead.
{{ product.metafields.custom.energie | divided_by: energie_ref | times: 100 | round: 2 }}
or you can even break it down as follows.
{% capture result %}
{{ product.metafields.custom.energie | divided_by: energie_ref | times: 100 }}
{% endcapture %}
{{ result | round: 2 }}
Let me know if it helps.
Thank you.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025