Hide line item options in CART if there is only one

Tourist
8 0 2

Our store maintains three options across all products (for sync purposes with an external Inventory Management app). They are

  1. Color
  2. Kind
  3. Size

On many products, there is only one option for each of these (e.g. "One Kind, One Size"). So on product pages, we've hidden the option selector successfully, on any option where there is only one available, since it's not necessary.

However, on our cart, the options still display like Screen Shot 2019-11-27 at 11.59.18.pngI'd like to hide line item options if there is only one available. I tried this, to no avail:

          {% for option in line_item.options_with_values %}
          {% assign hideColor = false %}
            {% if option.name == 'Color' and option.values.size == 1 %}
              {% assign hideColor = true %}
            {% endif %}
            {% assign hideMe = false %}
             {% assign hideColor = false %}
            {% if line_item.product.options.size == 1 %} 
              {% assign hideMe = true %}
            {% endif %}
            {% if line_item.product.options.size == 1 %} 
              {% assign hideMe = true %}
            {% endif %}
          {% endfor %}       


<div class="cart__meta-text">
<div class="cart-option" {% if hideColor %}style="display:none;"{% endif %}>
{{ item.product.options_with_values[0].name }}: {{ item.variant.option1 }}
</div> <div class="cart-option" {% if hideMe %}style="display:none;"{% endif %}>
{{ item.product.options_with_values[1].name }}: {{ item.variant.option2 }}
</div> <div class="cart-option" {% if hideMe %}style="display:none;"{% endif %}>
{{ item.product.options_with_values[2].name }}: {{ item.variant.option3 }}
</div> </div>
0 Likes