Skip to main content
Solved

Using dynamic content based on a custom property in the JSOn

  • November 7, 2025
  • 1 reply
  • 39 views

Forum|alt.badge.img+1

Hello! I want to use liquid code to show a dynamic text block when an order has specific product in it. When the order contains On Demand products (at least one) I want to show the block (only once). The On Demand poperty is visible in the JSON code in Klaviyo, but I cant seem to use the right liquid code to show the dynamic text block. I constantly see ‘message displayed without tags or variables’ when I try to preview the mail (see image below)
 

 The liquid code I am using

{% assign has_on_demand = false %}

{% for item in event.extra.line_items %}
  {% if item.properties %}
    {% for prop in item.properties %}
      {% if prop.value == 'On Demand Product' %}
        {% assign has_on_demand = true %}
        {% break %}
      {% endif %}
    {% endfor %}
  {% endif %}
  {% if has_on_demand %}
    {% break %}
  {% endif %}
{% endfor %}

{% if has_on_demand %}
  <p>Your order contains On Demand Products.</p>
{% endif %}

Part of the json where the property is filled
"properties": [
          {
            "value": "On Demand Product",
            "name": "Type"
          }

If I am looking at the pretty code I see the property is in Item → Extra → Line_items → 0: (or 1: or 2: if there ar more products) → properties: → 0: → value: On Demand Product

I really hope someone can help me out as I am trying to understand what I am doing wrong and how I can fix this. In the near future I also want to show those specific On Demand products in a different follow up mail (so only those items).

Kind regards, Trevor

Best answer by whereisjad

@Trev1414 I do not believe Klaviyo Django supports what are trying to do above.  Only recommendation I can offer is if you leverage instead custom action in your flow as described here: https://developers.klaviyo.com/en/docs/add_a_custom_action_to_a_flow#returning-outputs-from-a-custom-action

The output of your custom action could then be leveraged in subsequent email templates.  Hope this helps

 

1 reply

whereisjad
Expert Problem Solver IV
Forum|alt.badge.img+16
  • Expert Problem Solver IV
  • Answer
  • November 7, 2025

@Trev1414 I do not believe Klaviyo Django supports what are trying to do above.  Only recommendation I can offer is if you leverage instead custom action in your flow as described here: https://developers.klaviyo.com/en/docs/add_a_custom_action_to_a_flow#returning-outputs-from-a-custom-action

The output of your custom action could then be leveraged in subsequent email templates.  Hope this helps