Salva
Does this copy have something to do with it? To use as a reference.
$date_where .= $wpdb->prepare( ' AND post_date_gmt <= %s', $date_end );
}
$orders_query = "
SELECT ID FROM $wpdb->posts
$date_where
AND post_type = 'shop_order' AND post_status IN ('wc-processing', 'wc-completed')
";
$order_status = (array) apply_filters( 'atum/get_sold_last_days/orders_status', [
'wc-processing',
'wc-completed',
] );
$format = implode(', ', array_fill(0, count($order_status), '%s'));
$orders_query = $wpdb->prepare("
SELECT
ID
FROM
$wpdb->posts
$date_where
AND post_type = 'shop_order' AND post_status IN ($format)
", $order_status );
$query_columns = $query_joins = [];
$use_lookup_table = FALSE;
Also, I don't understand if the states work well for me, because the stock is reduced sometimes but at no time have we used the completed state, so the stock should not have been subtracted.