WooCommerce – Has onsale products function

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:

About the author

Remi Hey! My name is Rémi Corson, I'm a French WordPress Developer, I code stuff and I write from time to time ;-) Buy a coffee
Show your support

Related Posts


  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