Using variables within variables for Liquid?

19 1 3

Hello, I wish I knew the term for what I'm trying to do, but I basically want to input some liquid code as a string as part of another piece of liquid code. Here's an example of what I want to do:

This code will give me the name of the vendor for the product after checking out:

{{ order.line_items.first.product.vendor | json }}

I want to take the output of that and put it into something like this using custom metafields (likely using an existing app for custom metafields rather than making my own).

{{ vendordata.<INSERTVENDORNAMEHERE>.payment_info | json }}

So altogether, it would look something like this (though I'm sure this isn't how it's actually done hence why I'm asking the question). 

{{ vendordata.{{ order.line_items.first.product.vendor | json }}.payment_info | json }}

So what I'm wondering is, what's the best way (if there is a way) to do this? I've searched the docs but didn't get very far because I have no idea what the proper programming term is for what I'm trying to do. Reflection maybe? Not sure.


9 0 2

Hey there, @Breisoft !


I know it's been a while since you've posted this but I've just come across it.

I'm struggling with something similar and so far what I've been able to achieve was by using the {% capture %} tag, like this:

{% assign favorite_food = 'pizza' %}

{% assign age = 35 %}


{% capture about_me %}

I am {{ age }} and my favorite food is {{ favorite_food }}.

{% endcapture %}

Output: I am 35 and my favorite food is pizza.


However, one issue I'm running into is that after that it gets combined correctly but when rendered to the page it's rendered as a string and not processed as expected (an object).


Either way, I do hope this gets you a bit closer to the solution you were looking for even if it's for a new project you're working on nowadays since your message was written so long ago : )


Thanks and have a great day!

Fernando | Webflow -> Shopify Designer & Developer
Please leave me a like if my response has been helpful : )
Feel free to contact me for any questions and projects at