WooCommerce 2.1 - breaking change to layered nav
I spent a few hours on this issue this afternoon, and Google was no good to me, so I'd like to share.
I'd written a variation on the Woocommerce Layered Nav widget, that, instead of offering 'or' and 'and' as the filters, offers 'only' instead. This allows the user to see only once subset of products at a time, but keeps all options onscreen. When the site in question goes live, I'll link to it.
Woocommerce 2.1 broke the widget as it was no longer able to hook into the global (and now deprecated) woocommerce_layered_nav_query() function - this allows it to filter results based on query strings.
That function now resides in the WC_Query class.
It took a fair bit of time to see the refactoring that had taken place- if you're trying to traverse the codebase for something that's been refactored like this, where to start? Turned out that the function comments were the best place, as these (unlike function names) had not changed.
There are a fair few shops beset by the issue - a search for woocommerce_layered_nav_query returns many php errors on live sites, but scant help on the matter.
EDIT: I was asked for the method I used to get the type of nav I was looking for; here it is:
The comment there illustrates the end result. Probably not the cleanest code, and not thoroughly tested, but it appears functional. I ported it over from WC1.6.x whch I'd originally based it on.