PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Setting In Stock filter to default to On

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi
Is it possible, and if so how, to default the In Stock filter/switch to on?

Many thanks

Hello

Yes, it's possible to set the In Stock filter to be checked/enabled by default!

Solution

Add next code to your theme's functions.php file (child theme recommended):

add_filter('woof_get_request_data', 'woof_default_instock_on');
function woof_default_instock_on($data){
    $data['stock'] = 'instock';
    return $data;
}

How it works

This code uses the woof_get_request_data filter hook to automatically add stock=instock to the filter request data, making the In Stock checkbox checked by default when users land on your shop pages.

Where to add the code

  1. Recommended: Add to your child theme's functions.php file:
    • wp-content/themes/your-child-theme/functions.php
  2. Alternative: Use a plugin like"Code Snippets" to add the code safely

Important: Don't add this to the parent theme's functions.php as it will be overwritten when you update the theme!

This will make the In Stock filter active by default every time users visit your shop pages.

Also read: https://products-filter.com/manipulate-search-data-options/

Hi Alex

thanks for the instructions. They were clear, easy to follow and did what I asked.

BUT...

The changes force the filter to be on, so it can no longer be turned off.

Is it possible to have it default to In Stock but allow it to be switched to the other setting - I am not sure what to call the opposite of In Stock in this circumstance.

Regards
John

Hello John

I understand what you're trying to achieve, but there's a logical conflict here that we need to address:

The Business Logic Problem:

You have two conflicting requirements:
1."I want to show only In Stock products by default" (business preference)
2."But customers should be able to turn this off and see Out of Stock items" (customer freedom)

These two goals contradict each other. Here's why:

If your business goal is to show only available products (In Stock), then you shouldn't give customers the option to see unavailable items - that's your business decision.

If you want to give customers full control, then you can't enforce a default - that removes their control.

My Recommendations:

Option A: Pure Business Decision (Recommended)
If you don't want to show Out of Stock products, simply hide them at the WooCommerce level:
- WooCommerce → Settings → Products → Inventory
- Enable"Hide out of stock items from the catalog"

This way there's no filter needed at all - only available products are shown, period.

Option B: Pure Customer Control
Keep the Stock filter visible in your filter sidebar, let customers decide from the start:
- Show the checkbox prominently
- Don't force any default
- Let customers choose what they want to see

Why the code solution doesn't work well:

Any code-based"smart default" will create confusing behavior:
- First visit: only In Stock shown
- Customer unchecks filter: sees everything
- Customer refreshes page: back to In Stock only (?)
- Inconsistent experience across sessions

Bottom Line:

You need to make a clear business decision: either you control what's shown (hide out of stock entirely), or customers control it (give them the filter with no defaults).

The middle ground creates UX confusion and technical complexity that isn't worth it.

 

Hi Alex

Many thanks for the effort (& knowledge) you input to this response.

I am going to kick this one upstairs for their input and see what comes back. I will also read it a couple more times to try to fully understand what you are saying.

I'll be back in touch at some point, no matter what is decided, just to close the loop. However, the guy with the final decision is waiting for his wife to deliver a baby so it could be a good while before we close this one down.

Thanks again

John

Hello John

Thank you for collaboration and Welcome, in the meantime, if you have any questions while reviewing my response, feel free to ask - I'm here to clarify anything

Hi Alex

In checking things through for this support log we think we have identified a problem with the filter not correctly selecting products.

I am in the process of cloning the website (& removing client/order history etc) to allow you access to check everything once I can document the nature of the problem.

Are there any initial steps we can take to clear cache, re-index anything/everything to ensure we are not missing something simple before I go through the cloning process (it just failed at first time of asking)!

Regards

John

Hi John,

You can go ahead and create a clone of the site, then manually remove all orders and customer data - as they are related to your business and I not need them at all.
The important thing is to keep everything else exactly as it is — products as they are created and the filter configured exactly the same way.

On the cloned site, please also provide direct links and briefly describe what should or should not be displayed on each link (which products you expect to see, and which you don’t).

In the private section of this ticket, please share admin access to the cloned site. I’ll log in and check what’s going on — it could be a configuration issue or a conflict with another plugin. I’ll temporarily disable plugins as needed to test this.

Sometimes themes can also interfere with queries and filtering, so I’ll check that as well — possibly by switching to another theme, and also reviewing the current one.

For a more effective inspection, it would be best to also provide FTP access to the cloned site.

You can safely disable or even remove all cache-related plugins on the clone.

Hi Alex

Thought I would let you have a laugh at our expense without you having to do any work to prove to us that the issue is of our own making :-)

The process of creating the staging site and documenting the 'filter problem' has taken a few hours of my time. However the investment of time does, at this stage, let you and the plug-in completely off the hook.

It is true that certain products are not showing in the filter when they should! But the problem is that some Shoes have been set-up with the attribute 'Size' and others with the attribute 'Sizes'. We are only filtering on Sizes so if we use the filter anything with a Size attribute set doesn't show whether or not we have the InStock switch set.

Have a great day. If you are lucky you won't hear from us again for a while.

Thanks for support you have provided.

NO RESPONSE NEEDED

Regards

John

Hello John

Welcome :)