I want to exclude sale products from output related products.
In $args
i have field post__not_in
where i want to output array of values from wc_get_product_ids_on_sale();
function.
Code before $args
$related = $product->get_related( $posts_per_page );
$product_ids_on_sale = wc_get_product_ids_on_sale();
After i wrote args
$args = apply_filters( 'woocommerce_related_products_args', array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'no_found_rows' => 1,
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__in' => $related,
'post__not_in' => $product_ids_on_sale,
) );
But in frontend i see products not in sale and in sale
I try to echo $product_ids_on_sale it returns Array
As i understand, i need to return each value from array $product_ids_on_sale
separated with ,
Than i try to write foreach
like
$product_ids_on_sale = wc_get_product_ids_on_sale();
foreach($product_ids_on_sale as $result) {
echo $res,',';
}
But echo is not i want. I need to return
it
Also i try to write to 'post__not_in'
array_merge( array( 0 ), wc_get_product_ids_on_sale() )
Didn't help...
Please help me to exclude sale products!