Home WordPress Get a List of Products on Sale in WooCommerce

Get a List of Products on Sale in WooCommerce

get all sale products on woocommerce

Displaying sale products on WooCommerce is a nice feature to have. It helps to attract more customers and increase revenue. In this article, we will get all the products that are on sale using WP_QUERY class.

Check if product is on sale

We can simply check if a product is on sale on by using is_on_sale() function.

Get Products on Sale from All Categories

On contrary, getting a list of products that are on sale is a bit complex than check for a single product. We will use WP_QUERY class. In addition, we will use wc_get_product_ids_on_sale() function to get all the ids.

The above query will retrieve all the products that are on sale from all category.

Get Products on Sale from Specific Categories

We can also retrieve list of products from specific categories. For this we should pass ids of categories as an array.

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version