Output only products can be purchased via class Wp_query()

Question

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?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/output-only-products-can-be-purchased-via-class-wp_query/">

Output only products can be purchased via class Wp_query()</a>
0
, , nikita Abramov 3 months 0 Answers 24 views 0

Leave an answer