wc_get_order issue returns unexpected results
-
I’m seeing and odd behavior out of wc_get_order().
Background, I have an order that was created at “2020-03-08 20:12:45” and completed at “2020-03-08 20:12:47” according to the WC Order object
Now if I run wc_get_orders() with these argurments
array(5) {
[“date_created”]=> string(10) “2020-03-08”
[“status”]=> string(9) “completed”
[“limit”]=> int(-1)
[“orderby”]=> string(4) “date”
[“order”]=> string(3) “ASC”
}I get the WC_Order object back with no issues, but if I run the wc_get_orders() with these arguments
array(5) {
[“date_completed”]=> string(10) “2020-03-08”
[“status”]=> string(9) “completed”
[“limit”]=> int(-1)
[“orderby”]=> string(4) “date”
[“order”]=> string(3) “ASC”
}I get nothing back. The only difference is checking “date_created” versus “date_completed”.
To add to my confusion if I run these arguments setting “date_completed” to “2020-03-09” the order in question is returend.
array(5) {
[“date_completed”]=> string(10) “2020-03-09”
[“status”]=> string(9) “completed”
[“limit”]=> int(-1)
[“orderby”]=> string(4) “date”
[“order”]=> string(3) “ASC” }I’ve looked through the WC_Order object to verify it has a date_created and a date_completed of 2020-03-08 so why does wc_get_orders() return an empty array if I look for [“date_completed”]=> string(10) “2020-03-08” ??
// From the WC_Order object
[“date_created”]=>
object(WC_DateTime)#3282 (4) {
[“utc_offset”:protected]=>
int(0)
[“date”]=>
string(26) “2020-03-08 20:12:45.000000”
[“timezone_type”]=>
int(3)
[“timezone”]=>
string(15) “America/Chicago”
}
[“date_completed”]=>
object(WC_DateTime)#3286 (4) {
[“utc_offset”:protected]=>
int(0)
[“date”]=>
string(26) “2020-03-08 20:12:47.000000”
[“timezone_type”]=>
int(3)
[“timezone”]=>
string(15) “America/Chicago”
}
- The topic ‘wc_get_order issue returns unexpected results’ is closed to new replies.