Only Show Gift Messages on Shopify’s Packing Slip Template If They Are Present

Adding a check to your Shopify Packing Slip template to only show gift message if they are added can be accomplished with the following code:
{% for line_item in line_items_in_shipment %}
  {% for p in line_item.properties %}

    {% if 
        p.first == "gift" or 

        p.first == "To" or 

        p.first == "From" or

        p.first == "Message"​
        %}

    <p>{{ p.first }}: {{ p.last }}</p>

    {% endif %}

  {% endfor %}

{% endfor %}

Please note: This tutorial is for gift messages that are added on the product page, and passed through to the order as line items.

Can't find the answer in our documentation?
Contact Support