I am not getting the order ids that are completed on a date when using wc_get_orders, if there are 5 orders completed in the day 2022-04-19, then I need to get all the 5 order ids by using the date 2022-04-19. I have tried the below code but it’s not working
$args = array(
'status' => "Completed",
'return' => 'ids',
'date_completed' => '2022-04-19',
);
$orders = wc_get_orders( $args );
print_r($orders);
2
Answers
I have tried a lot with this and I can't get a correct answer with wc_get_orders or WC_Order_Query. I think it may be an issue with the date comparison. I have sorted the issue by taking the order id by SQL query
$date will be like 2022-04-19
You can use WC_Order_Query instead of using wc_get_orders
And according to WooCommerce Code Reference (https://woocommerce.github.io/code-reference/files/woocommerce-includes-wc-order-functions.html#source-view.93) order status should be ‘wc-completed’