WooCommerce – Has onsale products function

Remi | August 28, 2013 | in Tutorials

Here is a really quick snippet that i just coded to check if a WooCommerce website has onsale products or not. It simply returns true or false. That’s simple, but that’s useful! ;-) Here is the code, simply place the function within the functions.php file in your theme folder:

The author

About the author Remi: Hey! My name is RĂ©mi Corson, i'm a WordPress Expert Developer, i create high level themes and plugins, and i provide free stuff every week on this website!


  1. fredl


    I find this snipet really interesting by in my case the “woocommerce_get_product_ids_on_sale()” function doesn’t work. I also tried to replace it with “wc_get_product_ids_on_sale()”, but it always returns me “no onsale product” even if I have a few products on sale. It seems the functions returns an empty array. Do you a clue why this happens?


Leave a reply