I use 3 availability statuses: “in stock”, “out of stock” and “allow backups”. I want to export products that are only in stock status for XML. The problem is that woocommerce returns an “instock” value for both statuses: “in stock” and “allow backups”. Now the request looks like this:
$query = array( 'post_type' => 'product', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => '_stock_status', 'value' => 'instock' ) ) ); $wp_query = & new WP_Query($query); while ($wp_query->have_posts()) : $wp_query->the_post();
And it exports products with instock and backorders_allowed statuses. Perhaps there is a way to exclude products with "backorders_allowed".
source share