Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Collection "In Stock only" filter on by default

Collection "In Stock only" filter on by default

loadout
Visitor
2 0 0

My theme, IMPACT by maestrooo has the collection filters built in and one of the options is to filter by "in stock only".

 

I'm trying to have this filter selected by default, I've played with the code every which way but can seem to get it to work, can anyone help?

 

Replies 2 (2)

Anshul_arora
Navigator
453 128 100

Hi @loadout 

It is great filter to show your in stock products standout, there is a custom JS code which I can quickly write for you.

----------------------------------------

$(document).ready(function () {
$( '#Switch_option_ID' ).prop( 'checked', true );
});

-----------------------------------------

This small function basically make your toggle switch "On" after the page load. You can add this in any of your liquid code files, with a script tag. Just make sure to change the "Switch_option_ID" to your ID identifier of your filter.

Do not forget to include jQuery CDN before the code.

For ex: in this website, I show what will be the correct identifier for this:
https://prnt.sc/osrMUEtITw9z

"Impact" is a paid theme, so I can help you better if you can share the access to the store and your code.

The code piece I shared above is not tested on your store, so it may require some modifications as per your store.

Hope it helps.

Thanks

Please remember to like and accept the solution to help other store owners.

For Shopify Design & Development | Custom Coding -Visit Here

Jonezell
New Member
5 0 0

We were searching everywhere for this and finally found the Camouflage app which has this feature on the free plan:

 

https://apps.shopify.com/camouflage