Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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!
Solved! Go to the solution
This is an accepted solution.
Try with:
{%- if product.metafields.custom.type contains "SPD" %}
SPD Metafield Found
{%- endif -%}
This is an accepted solution.
Try with:
{%- if product.metafields.custom.type contains "SPD" %}
SPD Metafield Found
{%- endif -%}
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025