How to set 'In stock' as default in the 'Availability' filter?

Hello @MarkGasior ,

Greetings! I am Gina from the flareAI app helping Shopify merchants get $6Million+ in sales from Google Search, on autopilot.

Unfortunately, there is no built-in feature in Shopify to set the “In stock” option in the availability filter as the default option when a customer opens a collection page. However, you can achieve this using some custom code.

Here are the steps to set “In stock” as the default option in the availability filter:

  1. Go to your Shopify admin panel and click on “Online Store” > “Themes”.
  2. Find the theme you are using and click “Actions” > “Edit Code”.
  3. In the left-hand column, click on “Assets” and then click on “theme.js” to open the file.
  4. Scroll down to the bottom of the file and add the following code:
    $(document).ready(function() {
    // Set “In stock” as the default option in the availability filter
    if ($(“.collection-filter__form select[name=‘availability’] option:first-child”).text() == “In stock”) {
    $(“.collection-filter__form select[name=‘availability’] option:first-child”).prop(“selected”, true);
    }
    });
  5. Save the changes to the file and refresh your website to see the changes take effect.

This code will select the “In stock” option in the availability filter by default when a customer opens a collection page. If you want to set a different option as the default, simply change the text “In stock” in the code to the text of the option you want to set as the default.

Note that this code may not work with all Shopify themes, and it’s always a good idea to test any custom code changes on a development or test store before implementing them on your live website.

Gina