Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid where and reject Filters Not Working as Expected #1915

Open
spookyvert opened this issue Feb 21, 2025 · 1 comment
Open

Liquid where and reject Filters Not Working as Expected #1915

spookyvert opened this issue Feb 21, 2025 · 1 comment

Comments

@spookyvert
Copy link

The where and reject filters in Shopify Liquid are not functioning correctly. When used to filter collections based on properties like tags, they return incorrect results—often an empty array ([]) or null, even when matching products exist.

This issue directly impacted a Scheduled Drop, preventing products from displaying as expected. This led to a loss of visibility, sales, and customer engagement, which is critical for merchants who rely on Shopify for product launches.

There were no changes to the shop theme code in the past 4 weeks, yet due to this bug, the products did not appear as intended, revealing the issue.

Steps to Reproduce

Test Case 1: where Not Filtering Properly

{% assign test_array_filter = section.settings.collection.products | where: "tags", "contains", "foo" %}
<script>
  document.addEventListener("DOMContentLoaded", () => {
    console.log("Test WHERE filter:", {{ test_array_filter | json }});
  });
</script>

Expected: Returns an array of products with "foo" tag.
Actual: Returns null or an empty array ([]).

Test Case 2: reject Not Filtering Properly

{% assign products_to_display = section.settings.collection.products | reject: "tags", "contains", "bar" %}
<script>
  document.addEventListener("DOMContentLoaded", () => {
    console.log("Test REJECT filter:", {{ products_to_display | json }});
  });
</script>

Video:
https://www.loom.com/share/135d72b5c61d4441a86cd2da1aafa4c2

Expected: Returns all products excluding those tagged "bar".
Actual: Returns null or an empty array ([]).

@bakura10
Copy link

bakura10 commented Mar 6, 2025

The syntax you are using is not valid. Both reject and where only supports two parameters (the field to filter and the value) while you are using an extra one.

You won’t be able to use those filters for filtering tags here, you will need to do a for loop to be able to use the contains operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants