Hi Shopify Community,
I’ve been facing an issue with the Theme Editor not recognizing certain inputs in Liquid. I believe the problem might be related to how Shopify handles dynamically specified data versus pre-defined options in the code.
Here’s the background:
I’m trying to display a promo banner on specific collection pages selected in the Theme Editor. The setup is as follows:
Schema Setup
{
“type”: “collection_list”,
“id”: “selected_collections”,
“label”: “Allowed Collections”,
“info”: “Select the collections where the promo banner will appear.”
}
Liquid Logic
{%- assign allowed_collections = settings.selected_collections | split: “,” -%}
{%- if allowed_collections contains collection.handle -%}
{% endif %}
The Issue:
The settings.selected_collections data from the Theme Editor is consistently empty when accessed in Liquid, even after selecting collections and saving. Debugging confirmed this:
Selected Collections: {{ settings.selected_collections }}
This always outputs an empty value, regardless of what I select in the Theme Editor.
Debugging I’ve Done:
- Static Values Work: If I hardcode collection handles in the Liquid code, the promo banner displays as expected. The logic itself works perfectly.
{%- assign allowed_collections = “collection-1,collection-2” | split: “,” -%}
{%- if allowed_collections contains collection.handle -%}
{% endif %}
This confirms the issue lies with settings.selected_collections.
- Tested with Other Inputs:
I tried using other types like product_list, but the data from the Theme Editor was also not recognized.
-
Free Themes: I tested this logic with free Shopify themes and encountered the same issue, which suggests it’s not specific to a custom theme.
-
Alternate Logic Works for Pre-Defined Options:
I’ve had a similar issue when working with country restrictions. For example:
• If I use a dropdown in the Theme Editor with pre-defined country options set in the schema (e.g., DE, US, FR), the Liquid code correctly recognizes the selection.
• If I use a text field in the Theme Editor to allow users to enter country codes dynamically (e.g., DE,US,FR), Shopify fails to recognize the input in Liquid.
My Hypothesis:
The problem might be that Shopify’s Liquid cannot reliably work with inputs that are dynamically defined by the user at runtime via the Theme Editor. If the available options for a setting (e.g., collection_list, text) are not explicitly defined in the schema or the code, Shopify seems to fail to process the data correctly.
For example:
• A dropdown with pre-defined options works perfectly because Shopify knows all valid inputs in advance.
• A text field or dynamically defined collection list seems to fail because Shopify cannot validate or process the input effectively.
Question:
-
Is there a known limitation in Shopify where dynamically defined inputs (e.g., collection_list or text fields) are not processed correctly in Liquid?
-
Is it necessary to pre-define all available options in the schema for Shopify to handle these inputs properly?
-
If so, how can I create a flexible solution for scenarios where options (like collections or country codes) are not known in advance and need to be defined dynamically by the user?
This issue has been consistent across different themes (including free Shopify themes) and impacts key functionalities where dynamic user inputs are required. Any guidance or insights would be greatly appreciated!
Thank you!
Linus
Version: Enterprise-Version 1.4.2