Packing slip help: If order includes specific item, then include special text on packing slip

Topic summary

Goal: add a safety disclaimer to the packing slip only when the order contains a specific item or item type.

Proposed approach: use template logic to scan each line item and set a flag when a match is found. The user sketches an if-condition that checks whether a line item’s title contains a target string, then sets a variable to indicate the disclaimer should be printed. After listing items, they plan to test this variable and conditionally render the disclaimer block.

Key details: the implementation relies on templating control flow (e.g., {% if … %} and variables) and matching on line_item.title text. The exact syntax and variable scoping within the packing slip template are the core technical questions.

Status: no solution provided yet; the thread is an open request for how to correctly implement the conditional flag and subsequent rendering. Note: the included code snippet is central to understanding the desired logic.

Summarized with AI on February 14. AI used: gpt-5.

I need to add a product safety disclaimer to the packing slip so that if the order includes a specific item or item type, a block of text will be added to the packing slip.

I was thinking something like

{% if line_item.title contains "TEXT" %}

set VARIABLE to 1
{%endif%}

Then after I’ve listed all the items in the order I can check if the variable is 1 or undefined. If it’s 1, add the block of text. Otherwise, ignore.

How can I do this? Thanks