How to enable in stock filter by default?

How to enable in stock filter by default?

Kel06
Shopify Partner
4 1 1

How can I enable in stock filter by default in Impact theme?

 

I assumed the code below handles the liquid code for the in stock filer

 

 

            {%- if filter.param_name == 'filter.v.availability' -%}
              <label for="{{ id_prefix }}-{{ filter.param_name }}" class="bold">{{- 'collection.faceting.availability_label' | t -}}</label>
              <input id="{{ id_prefix }}-{{ filter.param_name }}" type="checkbox" class="switch instock" name="{{ filter.param_name }}" value="1" {% if filter.active_values.size > 0 %}checked{% endif %}>
            {%- else -%}
              <label for="{{ id_prefix }}-{{ filter.param_name }}" class="bold">{{- filter.label -}}</label>
              <input id="{{ id_prefix }}-{{ filter.param_name }}" type="checkbox" class="switch" name="{{ filter.param_name }}" value="1" {% if filter.true_value.active %}checked{% endif %}>
            {%- endif -%}

 

 

Replies 3 (3)

David_SHT
Globetrotter
605 125 128

Hi @Kel06 

This is David at SalesHunterThemes.
To check and add the function, it require to update theme code.
In this case I think you should contact with theme supporter, they will help you check and update the code.

We create fast Shopify themes, focusing on exceptional performance and seamless experience across all devices.

Try our Electro theme Free! (Now at Black Friday price)

Made4uo-Ribe
Shopify Partner
10036 2387 3013

Hi @Kel06 

 

Just remove the if statement the first input so it will be checked. Assuming that is the right code

 

            {%- if filter.param_name == 'filter.v.availability' -%}
              <label for="{{ id_prefix }}-{{ filter.param_name }}" class="bold">{{- 'collection.faceting.availability_label' | t -}}</label>
              <input id="{{ id_prefix }}-{{ filter.param_name }}" type="checkbox" class="switch instock" name="{{ filter.param_name }}" value="1" checked>
            {%- else -%}
              <label for="{{ id_prefix }}-{{ filter.param_name }}" class="bold">{{- filter.label -}}</label>
              <input id="{{ id_prefix }}-{{ filter.param_name }}" type="checkbox" class="switch" name="{{ filter.param_name }}" value="1" {% if filter.true_value.active %}checked{% endif %}>
            {%- endif -%}

 

For Shopify 2.0 Free themes, you can follow the instructions below. 

  • From your Shopify admin dashboard, click on "Online Store" and then "Themes".
  • Find the theme that you want to edit and click on "Actions" and then "Edit code".
  • In the "Snippet" folder, click on "facets.liquid" file
  • Inside the file, look for the code below 

NOTE: There will be multiple code like this in the same file. 

 

Ribe_Dagandara_1-1692311239872.png

 

  • You need to replace all of the said codes with the code below

 

{% if value.active or value.value == '1' %}
checked
{% endif %}

 

 

Code should look like this:

Ribe_Dagandara_2-1692311350188.png

  • Make sure to SAVE

Please don't forget to Like and Mark Solution to the post that helped you. Thanks!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
DaveHV
Tourist
5 0 1

Awesome, the facets.liquid tweak solved it for me 😀
Thank you for your help!