I am trying the following code and want to get all orders between dates and print them
$orders = $my_query->posts;
$order = wc_get_order( $order_id );
$order_data = $order->get_data(); // The Order data
$order_id = $order_data['id'];
if ($order_data['date_created']='12-12-2023')
{
echo('Order id-'.$order_id.'---order id end here-----');
}
Getting error Uncaught Error: Call to a member function get_data() on bool
2
Answers
please try to use this code:
$orders
should now hold all orders between given dates.It also works with dates that include hours : minutes : seconds :