Automatically check on a filter - Impulse Theme

David321
Visitor
2 0 0

I have filters set through Shopify's Search and Discovery but when a customer clicks through to one of my collections, I would like the Availability filter to be automatically checked and show only the available products.  It's fine to leave the checkmark there in case a customer would like to see sold out items and sign up for Back in Stock notifications, but I would like it to start as checked.  This should be easy, but I can't seem to find a good answer.

 

Thank you. 

Reply 1 (1)

PaulNewton
Shopify Partner
6339 579 1348

If they are coming from a navigation menu you can control that by using the specific filtered url.

Here one of the impulse demos set to have small variants selected

https://impulse-theme-apparel.myshopify.com/collections/muttonhead?filter.v.option.size=S 

 

Beyond that javascript is required, or deeper advanced customizations

Sample javascript for product availability to use in a custom-liquid section on collection templates:

<script>
document.onreadystatechange = () => {
  if (document.readyState === "complete") {
    document.querySelector('[name="filter.p.available"]').click()
  }
};
</script>

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org