Output only products can be purchased via class Wp_query()
I output all products with status ‘in stock’.
$args = array( 'post_type' => 'product', 'tax_query' => array( array( 'taxonomy' => 'taxonomy', 'field' => 'name', 'terms' => 'featured' ) ), 'meta_query' => array( array( 'key' => '_stock_status', 'value' => 'instock', 'compare' => '=', ) ) ); $products= new WP_Query( $args );
If I added to cart single product in stock (1). Status keeps ‘in stock’ and the product is still listed but this item is not available at this time due to pending orders.
How to output only product can be purchased?