What goes wrong

A shopper chooses Red and In stock. The hoodie appears, because the hoodie is in stock and the hoodie comes in red. They click through, pick red, and find that red is sold out. The filter did exactly what it was built to do, and it was the wrong thing to build.

Does your filter count the parent?

Change which variation is sold out and see the two ways of counting side by side. Nothing you type leaves this page.

What Siftwren changes

When In stock is chosen, Siftwren switches on WooCommerce’s own option for hiding out-of-stock variations in attribute filtering, for that request only. WooCommerce then matches the variation’s own row in its lookup table and lifts the result to the parent. That is one line of code, and it is the line the rest of the plugin is built around.

The count beside Red is worked out the same way, so it falls when the red variation sells out, and the product leaves the list.

What it needs

Without the last one the plugin does not hide anything on its own. Showing sold-out items is sometimes what a shop wants, and nothing is hidden unless a shopper asks.