New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of stock, hidden products are not completely hidden #17365

yukikatayama opened this Issue Oct 24, 2017 · 4 comments


None yet
5 participants

yukikatayama commented Oct 24, 2017

Affected ticket


What I expected

When products are out of stock and Out of Stock Visibility is enabled, the /shop catalogue should show the in stock products normally.

What happened instead

There are blank spaces where the out of stock products seem to be:

Link to screenshot:

Steps to reproduce the issue

WC 3.2.1

  • In Settings > Product > Inventory, check hide out of stock visibility
  • Place a few products in out of stock. In the shop catalogue, there will be empty spaces where the out of stock products are hidden.

This comment has been minimized.


mikejolley commented Oct 25, 2017

Zendesk gives me access defined so I cannot check the ticket details, but I can confirm it's not broken. I do have an idea what it is though. From 3.x+, visibility is determined by a term. Out of stock products get an 'outofstock' term which is then used to exclude them from the store.

I've seen this go wrong after imports due to missing 'terms'. Thats not something we can work around but it might be good to check if the user did some imports/merges and with what. You could edit the product, make it in stock, then back out of stock. That should re-assign the outofstock term.

But before that, just ensure the terms are actually present -

In system status, ensure there is only one of each visibility term defined:

woocommerce status local wordpress dev wordpress 2017-10-25 13-03-18

If there are duplicates e.g. out-of-stock-2, the duplicates need to be removed. Again this could be the result of botched import. If you change this line to true, you'll be able to edit the terms via admin and clean it up.

Ping on slack if any of that is unclear.

@mikejolley mikejolley closed this Oct 25, 2017


This comment has been minimized.


RistoNiinemets commented Oct 28, 2017

Same issue for me. The site does not have any importers or anything and that happened just after upgrading to 3.x.

Quite the same issue as in #15114, #15455.

I tried running the PHP code from one of the issues, but that did not help. Also just saving the missing products does not help also, but I'll need to change the status and then save. After that, the products will be counted out of the loop.

I upgraded the same site on dev and staging environment (which all differ actually in terms of the server) and same things happened.

My guess is, some weird bug is in the data migration process.


This comment has been minimized.

alanpachuau commented Nov 22, 2017

I've got the same issue after upgrading to WC 3.2.5 and WP 4.9. I checked my database and I have "_stock_status" in meta. So I used meta_query and hook into product query action as below.

add_action('woocommerce_product_query', 'show_only_instock_products');

function show_only_instock_products($query) {
        $meta_query = $query->get( 'meta_query' );
        $meta_query[] = array(
                'key'       => '_stock_status',
                'compare'   => '=',
                'value'     => 'instock'
        $query->set( 'meta_query', $meta_query );

This solves my problem. Hope it helps.


This comment has been minimized.

RHunt21502 commented Dec 20, 2017

Thank you for posting this alanpachuau. Your script solved my issue in part on the woo commerce archive and category pages. I am also experiencing a similar behavior on pages using the avia product grid where out-of-stock items are still being displayed with "read more|show details" for options instead of being hidden per woo commerce settings "Hide out of stock items from the catalog" option. This would be with theme Enfold 4.2

Update: 12/22/17 I can confirm our issue is caused by failure to assign 'outofstock' term to item. Was able to correct issue per @mikejolley post of 10/25/17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment