How to set the default availability as in-stock for Search & Discovery?
How it works
As Search & Discovery doesn’t support setting default filter values, we can only modify the collections link through JavaScript.
Javascript code
1 | <script> |
How to use
- Online store > themes > Actions > Edit code > theme.liquid
- Copy the code above and paste it before the
</body>
tag. - Find this piece of code.
1 | const linkModifier = new LinkModifier(['blocked', 'keywords', 'go', 'here'], ['filter.v.availability=1', 'filter.v.color=red']); |
If we want some pages to not have default filter options, we can add those collection handles in the first parameter. If not, keep the array empty []
.
The second parameter is for the parameters that you wish to set as defaults, with the format of filter name=filter value
.