Forum Discussion
elena14
7 months agoPractitioner
Loop through a catalog to display the product a user has as a custom attribute
Hello,
So I am trying to display some Liquid logic into an email template. The idea is that I have a catalog named house_properties with fields: id, name and description.
Each user has a custom ...
DavidO
7 months agoStrategist II
Hi elena14
I'm assuming the house properties catalog is assigned early on so the loop knows which catalog to loop through.
Otherwise this looks pretty good to me except I can't see where you are using the assigned user_prodcut_id? Should it be part of your IF statement rather than the custom attribute liquid so the code would look like this:
{% assign user_product_id = {{ custom_attribute.${user_product_id} }} %}
<!-- Loop through each row in the catalog -->
{% for row in house_properties %}
<!-- Loop through each item in the current row -->
{% for item in row %}
<!-- Check if the item name contains the user's custom attribute -->
{% if item.id == user_product_id %}
{{ item.name }}
{% endif %}
{% endfor %}
{% endfor %}
Related Content
- 12 months ago
- 5 months ago
- 10 months ago
- 8 months ago