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:
WooCommerce – Has onsale products function
2 responses to “WooCommerce – Has onsale products function”
-
Hello!
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?
Thanks!
-
You’re right, this function has been deprecated and was replaced by wc_get_product_ids_on_sale(). I updated the post.
-
Leave a Reply
You must be logged in to post a comment.