All Collections
Troubleshooting
Hiding Properties or Products
How To Hide Custom Product Properties In Cart
How To Hide Custom Product Properties In Cart

This article will show you how to hide custom product properties in the cart.

Strauss Van Wagenen avatar
Written by Strauss Van Wagenen
Updated over a week ago

This article will show you how to hide custom product properties in the cart.

Your theme's templates/cart.liquid or sections/cart-template.liquid file will have a section of code that looks something like this:

{% for p in item.properties %} 
{% unless p.last == blank%}
{{ p.first }}: {{ p.last }}
{% endunless %}
{% endfor %}

After the "{% for p in item.properties %}" line, add "{% assign first_character = p.first | slice: 0 %}". Then after the "{% unless p.last == blank" %} section, add " or first_character == '_' ".

It should end up looking close to this:

{% for p in item.properties %} 
{% assign first_character = p.first | slice: 0 %}
{% unless p.last == blank or first_character == '_' %}
{{ p.first }}: {{ p.last }}
{% endunless %}
{% endfor %}

  • It won't always look exactly the same but as long as you've added "{% assign first_character = p.first | slice: 0 %}" and "or first_character == '_' ", it should work!

  • Note the addition of line two, the setting of the variable "first_character" and checking its contents (line three) for an underscore before printing.

  • Adding this code prevents custom product properties that start with an "_" character from showing.

Advanced property removal:

Rarely, the liquid will not exist in the common files listed above and a developer may need to edit more complex code within the themes JavaScript files. Here is an example of what this might look like:

if(item.properties) { 
$.each(item.properties, function(title, value) {
if (value && title[0] != '_' && value[0] != '_') {
cart_items_html += '<div class="line-item">' + title +': ' + value + '</div>';
}
});
}

  • Remember! All you need to do is make sure that any property starting with a "_" is removed!

If you're still having issues, reach out to support and we'll get you the resources you need!

Did this answer your question?