I noticed today that if I use the Products element and set it to show only “On Sale” products, in the event that there are no products on sale it instead shows all products.
At the very least, I’d expect it to return no results in that scenario rather than every single product. Ideally though it’d also allow for customization of an error message to display when there is a situation where no products are on sale.
In my situation, I have a WooCommerce site with 770 products I am building. I tried to add a Products element for an On Sale category on the homepage and realized it was showing all 770 items instead. Then I realized it was doing that because I actually had 0 products with a sale price at the time, and once I added a sale price then it worked as expected. This led me to realize though that this On Sale filter in the Products element is not working as expected in the scenario where no products are actually on sale.
That’s unfortunately not my experience. I only get that “no products were found matching your selection” if I choose “Featured” for example (since no products are Featured either). But when it comes to Sale, it shows everything when no products are actually marked as on sale. Once I set a sale price though then it will show properly.
Here’s a few screenshots of how the query is setup in case this helps at all. Or if you still can’t reproduce then I can offer remote access to it for further troubleshooting.
Notice the screenshot above shows the total results of 770 products which is 100% of the products in the website as opposed to just on-sale products (where I currently have 0 on-sale products).