How do I hide line item properties that start with an underscore in cart, invoice templates and packing slips?
Shopify by default will hide any line item properties that start with an ”_”.
They’ll be visible when you view orders from the admin, but not on the cart page, thank you page and the default Shopify invoice and packing slip templates.
If you’ve set up a custom invoice or packing slip template, it’s possible your template isn’t set to ignore properties that start with an ”_”.
Hiding line item properties:
Section titled “Hiding line item properties:”Note: before you edit the file, create a backup of it by copying the file into notepad or another place.
-
Find the template file. If this is for your cart, it will be in your theme files. If this is for your invoice or packing slip template, it will be in the Settings section in your Shopify dashboard.
-
Open the file and look for:
{%- for p in properties -%}- Immediately after that line add the two assign/unless statements shown below:
{% assign first_character_in_key = p.first | truncate: 1, '' %}{% unless p.last == blank or first_character_in_key == '_' %}- Find the matching
{%- endfor -%}that closes theforloop, and insert the following line directly above it:
{%- endunless -%}- Confirm that your code looks similar to below:
{%- for p in properties -%} {% assign first_character_in_key = p.first | truncate: 1, '' %} {% unless p.last == blank or first_character_in_key == '_' %} <div class="cart__property"> <span class="cart__property-key">{{ p.first }}:</span> <span class="cart__property-value">{{ p.last }}</span> </div> {%- endunless -%}{%- endfor -%}If you need assistance with this, please contact Propel support. We can request access and attempt to modify your template.