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?
0
php, sql, woocommerce
4 years
2019-11-05T03:26:35-05:00
2019-11-05T03:26:35-05:00 0 Answers
80 views
0
Leave an answer