Now that we have lookup table for products, maybe there are some approaches we could explore to support filtering variations by attributes + in stock/out of stock.
Ref old issue with some proposed solutions: https://github.com/woocommerce/woocommerce/issues/20689
@peterfabian What would it take for this issue getting some focus?
Expectations:
Alternate options expected:
Thanks
I am also waiting for a solution to this problem.
It should be possible to hide products variations that are out of stock during filtering.
@KoolPal It's been assigned high priority, so it will get more focus and attention after the 4.0 release.
@peterfabian Thank you for responding.
Would it be possible for someone to share a code snippet in the interim for all of us to get by this monstrosity?
Thanks
Finally. This makes me happy. Great to see this topic is on the high priority list.
What are the new lookup tables called? Has anybody developed filter queries against these yet?
This would be a really high priority item to fix. This is a really fundamental requirement to lot of shops.
@ifede84 @Moultrex @woolityourslef @khmahfuzhasan, fyi.
The lookup table is called {$wpdb->prefix}wc_product_meta_lookup.
Now WooCommerce 4.0 has been released, what's the status on this?
As soon as fix the fatal errors in 4.0.0, we can get to the nice things, such as this. No timeline yet, but it would be nice if we could ship it in 4.1 in May.
Noting that out of stock filtering was also raised as a request in 2795671-zen
@chad1008 What are you talking about?
Logging another request for this feature from a different site @mischasigtermans - nothing urgent or signifying a change or update
Still not included in the Release notes of 4.1 Beta1 nor in Beta2.
Will this ever be included? I'm actually waiting for this since 2014. :)
Hi @Alessandro-4EYES, I'm working on a fix for this issue right now. It won't make it to 4.1 but hopefully we'll be able to include it in 4.2.
Please be patient with me, I joined Automattic two months ago and I'm completely new to WooCommerce, WordPress and even PHP. 😅
@Konamiman glad to hear you are working on this! Welcome to your new role!
This improvement will be much needed for a lot of shops. I would think anyone selling products with sizes (clothing, shoes, so many things) will be interested. We will be excited to hear how this goes.
Hi @KoolPal, @PriitGit, @mischasigtermans, @Alessandro-4EYES, @gibarra1, @ifede84, @khmahfuzhasan.
Here's a pull request that fixes the issue: https://github.com/woocommerce/woocommerce/pull/26260. It still needs to be reviewed by my team, but you might be interested in taking a look as well meanwhile - especially the logic for the widget counters as explained in the PR description, I hope it makes sense.
@Konamiman Thanks. Where do we add our feedback? Here OR on #26260?
I have the biggest disconnect with
I DO NOT WANT to hide out of stock items from the catalog. However, OOS variables should be hidden when the filter is used.
Let me EXPLAIN why is this important as a business owner if I hide OOS items :
At the same time, I want to SHOW the customer in stock items when they use the filter. You may choose to move OOS variables to end of loop if you face a technical issue.
Please understand that at times all need to view the business angle rather than just the technical side of things.
I hope this makes sense. Please ask if I am not clear.
Thanks
Hi @KoolPal, thanks for the feedback, I'll discuss it with my team. Posting feedback here is fine by the way.
Hi @KoolPal, we've been discussing about this. In principle this seems like a somewhat niche case: if you mark or clear the "hide products out of stock" setting the logical behavior seems to be that these products will be always hidden or shown, regardless of whether filtering is in place or not.
Note however that there's a woocommerce_product_is_visible filter that you could use to get the behavior you describe with custom code like this (assuming that the "hide products out of stock" setting is disabled):
add_filter('woocommerce_product_is_visible',
function($is_visible, $id) {
if(!$is_visible) {
return false;
}
if ( empty( WC_Query::get_layered_nav_chosen_attributes() ) ) {
return true;
}
$product = wc_get_product($id);
$stock_status = $product->get_stock_status();
return $stock_status !== 'outofstock';
}
, 999, 2);
That said, we'd love to hear other opinions, so @PriitGit, @mischasigtermans, @Alessandro-4EYES, @gibarra1, @ifede84, @khmahfuzhasan and anyone else reading this: please feel free to comment on this topic.
@KoolPal exactly describes the issue here. I don't think his examples is a 'somewhat niche case' at all, but a very basic expectation of how out of stock filtering should work. Let me clarify once more from my end.
Currently, when a visitor is browsing a WooCommerce webshop, let's say a clothing store, and he wants to filter on his size only, Medium for example, then WooCommerce starts showing ALL the products that HAVE the size Medium available, regardless of the stock. The potential customers clicks an item, gets redirected to the product page, likes the product, hits the size dropdown to select Medium and then finds out this product is actually out of stock.
We, as WooCommerce users (like @KoolPal says), think that the option "Hide out of stock items from the catalog" filters out all the out of stock options for in my example used filter on Medium, however, it does not. This issue is seriously annoying for potential customers and is even decreasing conversion.
Please, fix this terrible issue once and for all.
@mischasigtermans describes it perfectly. Can't add anything more...
Hi @mischasigtermans. Sorry, I think there's a misunderstanding here.
We, as WooCommerce users (like @KoolPal says), think that the option "Hide out of stock items from the catalog" filters out all the out of stock options for in my example used filter on Medium, however, it does not.
And indeed, this is what the pull request fixes: when the "Hide out of stock items from the catalog" setting is active, variable products won't appear in the catalog when filtering by variations that are out of stock - if you look at the testing instructions in the pull request you'll see that I use an example that is very similar to yours (shoes and colors).
What I was referring to as "niche case" is the comment where @KoolPal says that enabling the setting should hide out of stock products in the catalog _but only when filtering_. We think that the setting should continue working as it does now: hiding out of stock products both when filtering and when not (and I provided a code snippet that allows to achieve the requested functionality by using a filter).
Again, sorry for not being clear enough in my last comment. Taking a look at the pull request can provide more insight about how the fix works, but of course I'm here to further clarify things if needed.
@Konamiman I can work with that and see your point.
So, can we expect this pull request in the next update (4.2)? :)
@Konamiman
I can see TWO use cases emerging here. Let me try to explain them
Use Case 1 (I think this has been handled by your pull request)
Go to Settings > Products > Inventory, mark "Hide out of stock items from the catalog".
Product A
Size Small - 0
Size Medium - 1
Size Large - 0
Product B
Size Small - 0
Size Medium - 1
Size Large - 1
In Shop filter on Medium or Large
Expectation: Show : Product A Size Medium, Product B Size Medium, Product B Size Large
Uses for this:
Use Case 2 (I think you are calling this niche use case)
Go to Settings > Products > Inventory, **UNCHECK** "Hide out of stock items from the catalog".
Product A
Size Small - 0
Size Medium - 1
Size Large - 0
Product B
Size Small - 0
Size Medium - 1
Size Large - 1
In Shop filter on Large
Expectation: Show : Product B Size Large & Product A Size Large at end of loop.
Uses for this:
It would be appreciated if you could provide a CHOICE to the Store owner to use EITHER option
P.S. Your code snippet in https://github.com/woocommerce/woocommerce/issues/25524#issuecomment-628689533 did not help for Use Case 2
Please let me know in case you want me to elaborate further or provide any clarifications.
Thanks
So, just updated some of our sites to WooCommerce 4.2, but don't see a fix for this issue added. Any ETA already? My clients are getting frustrated.
So, just updated some of our sites to WooCommerce 4.2, but don't see a fix for this issue added. Any ETA already? My clients are getting frustrated.
Same here.
I was able to "hide" the products based on the filter descibed https://github.com/woocommerce/woocommerce/issues/25524#issuecomment-628689533
But this is not a clean solution when using pagination or lazy-load as the filter gets applied per page resulting in some pages having only 1 product displayed and others 10.
Correct @Alessandro-4EYES, feels a bit hacky. We've removed this implementation.
I thought this was something I haven't configured correctly in woocommerce and looked to find workarounds for years. I am glad I found this.
The people I work for find it incredible that I can't make woocommerce to filter products based on the sizes that are available in stock and not show/hide the ones that have zero stock, with backorders not allowed or that are just out of stock.
It's essential for many shops having different sizes in their products that people can filter through variations to find the ones that are available in stock.
Is there any news on this? We should be thousands that could use this to work this way. Currently there is no use for filters for these kind of shops.
One of the first things a visitor to a website of clothes, shoes, accessories, etc would like to know and see on the screen are which things are in stock in his or her size. And not see anything else that is not on his or her size. Filtering by stock in these websites its more important than any other filter.
What's the point to filter by a Red color, or a Small size, or a size 7, if I cannot filter for what is available, what I can buy, what's in stock?
The point of Filters is to save time and I think this is the first one in order of importance so the others have meaning and can be useful as well.
Woocommerce must notice this affect all these kind of businesses and in this cases now our websites don't perform as well as others due to this. I really hope this is on the works and is to be released soon.
The best would be that we could filter the variations that are in stock from the ones with stock zero and even from backorders.
A customer reported this issue: 3075025-zen
This is something really needed,,
Basically when filtering attributes don't show items with no stock
Or simply add an option to hide from the shop variations that don't have stock
Hi @Konamiman, what's the status of this task? Does it still get any focus?
I still don't see anything mentioned in the next release WooCommerce 4.3 Beta 1.
Thanks!
It's marked as a high priority issue and we're doing a cleanup of those now, so @Konamiman should be looking into this soon.
It would be useful if people who commented here could chime in on how important the use case 2 as mentioned in @KoolPal s post is, as it seems like we can handle use case 1 with the PR we have from @Konamiman now, so my thinking was--maybe it makes sense to cover the use case 1 by merging the PR and seeing how much interest there is for use case 2?
I think my observations are related here. In my theme, if I hit refresh 1-7 times the hidden stock suddenly shows. And if I select an out of stock size, and say add to cart, it tells me to add something to the cart lol. Because that size should not exist and by selecting hide out of stock products, it disables the Out of Stock message. Thereby utterly confusing the customer and making woocommerce look flakey to my clients. This needs to be fixed before I lose the "DONT USE SHOPIFY" argument lol . I see that when I do it with storefront theme, I see the full stock for an instant and then its replaced with the proper stock. Clearly a workaround applied there lol. Anyway if this helps, I noticed that if I have the browser code inspector enabled, none of this ever happens. Like it interrupts the glitch. Of course I have disabled every plugin, and tried many themes, duplicating these results. It's Woo.
@Konamiman Any updates..?
@Konamiman Any updates..?
damn, that issue persist here for years
Any date for this to be on the works? @Konamiman
Thanks
Hi @mischasigtermans, @mugukamil, @fedosh. Sorry for having been so silent lately.
I'm happy to announce that the fix for this issue will be included in WooCommerce 4.4. The release is scheduled for August 18th, but there's a beta available now in case you want to give it a try meanwhile.
Hi @mischasigtermans, @mugukamil, @fedosh. Sorry for having been so silent lately.
I'm happy to announce that the fix for this issue will be included in WooCommerce 4.4. The release is scheduled for August 18th, but there's a beta available now in case you want to give it a try meanwhile.
Hello I've updated to the latest available version 4.5.2 but still don't see a fix for the issue of this thread. Any info on that?
Me neither. @Konamiman Are you sure we're on the same page regarding this issue? Black Friday around the corner.
The fix was released in 4.4 but reverted in 4.5.2:
https://developer.woocommerce.com/2020/09/14/woocommerce-4-5-2-fix-release/
We thought we would be able to solve this with a more light-weight approach, but apparently missed some of the complexity coming from the different product setup options:
Therefore, we decided to take a step back and do this properly, but it would probably require a bit more dev effort and custom table to look up these options quickly, without joining multiple meta tables, etc. Please stay tuned for updates.
Appreciate you guys are looking into this as a priority but if it could be a top priority and we could get a rough ETA on a fix so we can let our clients know if would be very much appreciated.
Another user that would be interested in this 25458084-hc.
I am not a programmer but I don't understand why you cannot utilize the same fix as the one that have been available for over 5 years on Shopify. A script run every 5-10 minutes and for anything in stock it ads a tag i.e. for T-shirts cf-XS, cf-S etcetera then the filter is hooked up so it will show any tags with "cf-" as prefix as choices on the webshop. Its super light with no noticeable effect on load-time.
Ref #28368, #27935
Is there an update for solving this problem?
Thanks.
Today I updated WooCommerce to 4.8.0 but unfortunately no solution for this problem...
Hi!
Are there even any roadmap to solve that bug?
Same thing with "hide grouped products whn out of stock"?
same here....waiting for a fox for this. VERY VERY annoying.
Most helpful comment
Hi @mischasigtermans, @mugukamil, @fedosh. Sorry for having been so silent lately.
I'm happy to announce that the fix for this issue will be included in WooCommerce 4.4. The release is scheduled for August 18th, but there's a beta available now in case you want to give it a try meanwhile.