If statements not working for value comparison

Hey everyone

I want to apply some custom boolean logic for my product-grid using a custom metafield.

The metafield named “type” (product.metafields.custom.type) is a single line text. When printing out the value, this is what is printed out:

product.metafields.custom.type: [“SPD”]

product.metafields.custom.type.value: SPD

product.metafields.custom.type.type: list.single_line_text_field

product.metafields.custom.type.list?: true

When writing an if statement, when using the product.metafields.custom.type.value variable, it is not entering the statement

{%- if product.metafields.custom.type.value == 'SPD' %}
                SPD Metafield Found
              {%- endif -%}

Is there something special with liquid that I’m missing? Does the .value operator not return the literal string? Thanks!

Try with:

{%- if product.metafields.custom.type contains "SPD" %}
    SPD Metafield Found
{%- endif -%}