Skip to main content

I’ve tried about every different iteration of this and I get “Your template contains placeholders we can't replace. No problem, de-select that option to view a preview.” when I try to preview

All of these output correctly as template tags if I remove the conditional

Doesn’t work

{% if event.extra.fulfillment.line_items|size > 1 %}products{% else %}{{ event.extra.fulfillment.line_items.0.name|default:'product' }}{% endif %}

 

Does work (outputs product’s name correctly)

{{ event.extra.fulfillment.line_items.0.name|default:'product' }}

Adding to this, moving the conditional from > 1 to == 1 works

{% if event.extra.fulfillment.line_items|size == 1 %}{{ event.extra.fulfillment.line_items.0.name|default:'hat' }}{% else %}hats{% endif %}


Hi there,

Is this the Shopify Fulfilled Order Metric? If so, it looks like you’re missing an “s” from fulfillment (should be fulfillments), and you also need to access the first item of fulfillments to get line_items, so it should look like this:

{% if event.extra.fulfillments.0.line_items|size > 1 %}products{% else %}{{ event.extra.fulfillment.line_items.0.name|default:'product' }}{% endif %}

If it’s not Shopify Fulfilled Order, could you send the event payload you are testing (minus identifying info) and the metric name?


That looks like it was actually a typo, but there still seems to be a bug. It’s the Shopify Delivered Shipment metric

 

This works

{% if event.extra.fulfillment.line_items|size == 1 %}{{ event.extra.fulfillment.line_items.0.name|default:'hat' }}{% else %}hats{% endif %}

 

This does not work

{% if event.extra.fulfillment.line_items|size > 1 %}hats{% else %}{{ event.extra.fulfillment.line_items.0.name|default:'hat' }}{% endif %}


Hi there,

Thank you for the clarification! Both of those snippets work in my testing for the Shopify Delivered Order Metric. What if you tried using the “Item Count” field instead of the size of the line_items array? So

{% if event|lookup:’Item Count’ > 1 %}...{% endif %}
 

Additionally, if you print the size of the line_items array under fulfillment, is it correctly outputting the length of the array? I would check that to see if it’s isolated to the ‘size’ function.

Last piece,  you could try explicitly casting the output of size to an int by using floatadd:0:

{% if event.extra.fulfillment.line_items|size|floatadd:0 > 1 %}…

If none of those work, I can report this as a bug for our team to look into


None of those work, all the same error (which is actually no error, I only see it because I opened up the dev console), this is all I see, it was super confusing

 

 

I’m also editing a text only email in the source code which maybe is where the bug is here