Discussions
Best way to use with_scope and params to filter content (Shop)
about 8 years ago by Kations
Hi,
what is the best way to filter with_scope and multiple params like category, color, size etc. and the case that maybe only one or two params are selected.
Example:
{% with_scope category: category, colors.in: [color], size.in: [size] %}...
When a user clicks on a category, no product appears. If i delete the colors.in and size.in it works.
My current workaround is:
{% assign category = params["category"] | default: '/^/' %}
{% assign size = params["size"] | default: null %}
{% assign color = params["color"] | default: null %}
and a lot of if.. else if.. else.. but i think there must be a cleaner approach
Thanks