I have a view that shows commerce products, with an exposed filter to show only items with stock >= 0. So, if the checkbox is checked, it will hide out-of-stock items.

I would like to reverse this so that if the checkbox is checked, all items are shown, and if it is not checked, only the filtered items (stock >= 0) are shown.

The label could then be changed to "Reveal items that are currently not available".

Any idea how to do this? I could probably do this with some hook_form_alter() and stuff, but I am more interested in something to configure with the Views UI.

(Not that I shy away from custom modules in general, but I like to avoid stuff that is hardcoded to one specific view name and display id and field name..)

1 Answer 1


I have not tested this but you might be able to do it by using 2 filters. Add a non exposed filter that filters by stock > 0. Make sure it is below your current filter. Views filters in order from top to bottom. So if the page loads and that check mark is un-checked you will only see products with a stock greater than 0. If they then check the box it will re-load and filter by your stock >= 0. That might work. As I said I have not tested this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.