Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
I have the following code
Solved! Go to the solution
This is an accepted solution.
Hi @molten_frog,
You can try this code:
{%- assign each_ingredients = product.metafields.product.ingredient_list | split: "|" -%}
{%- for ing in each_ingredients -%}
{%- capture texting -%}product_ingredients_{{ product_ingredients_ }}{%- endcapture -%}
{{ shop.metafields.product_ingredients[texting] }}
{% endfor %}
Hope my answer is clear to you. Please mark it as a solution if you find it helpful.
Hi @molten_frog
that code you implemented prints 2 strings concatenated, and it behaves correctly.
Can you try something like this?
{%- assign each_ingredients = product.metafields.product.ingredient_list | split: "|" -%}
{%- for ing in each_ingredients -%}
{%- capture n_ing -%}
{{ 'shop.metafields.product_ingredients.product_ingredients_' | append: ing }}
{%- endcapture -%}
{{ n_ing }}
{%- endfor -%}
Thanks @drakedev I have tried this myself. Unfortunately it does the same as my original code 😞
This is an accepted solution.
Hi @molten_frog,
You can try this code:
{%- assign each_ingredients = product.metafields.product.ingredient_list | split: "|" -%}
{%- for ing in each_ingredients -%}
{%- capture texting -%}product_ingredients_{{ product_ingredients_ }}{%- endcapture -%}
{{ shop.metafields.product_ingredients[texting] }}
{% endfor %}
Hope my answer is clear to you. Please mark it as a solution if you find it helpful.
Hey @LitExtension this worked great. Only slight change was
{%- capture texting -%}product_ingredients_{{ ing }}{%- endcapture -%}
Thanks very much for that. I will mark it as a solution, but if you could make the change so that anyone else looking doesn't get confused 🙂
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024