Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 82367

Woocommerce – only show discounted/sale products

$
0
0

Replies: 0

Hi, I would like some help!

I am trying to only show discounted products on my page with woocommerce. I have tried to make changes to the woocommerce “class-wc-query.php”, as explained here: https://www.kathyisawesome.com/woocommerce-modifying-product-query/, but it does not do the trick. Could there be something overriding my code, or isn’t it triggered? I know that the $product_ids_on_sale works since i got badges on the sale-items. This is what I have changed in the “class-wc-query.php”:

/**
* Hook into pre_get_posts to do the main product query.
* @access public
* @param mixed $q query object
* @return void
*/
public function pre_get_posts( $q ) {
if ( ! $q->is_main_query() ) {
$product_ids_on_sale = wc_get_product_ids_on_sale();
$q->set( ‘post__in’, (array) $product_ids_on_sale );
}

My web-page: http://www.fersketilbud.no/

Any help?


Viewing all articles
Browse latest Browse all 82367

Trending Articles