Merge pull request #15907 from tractus/fix-order-date-query
Fixes major issue with wc_get_orders with both date_before and date_after specified
This commit is contained in:
commit
7046b480a0
|
@ -57,7 +57,7 @@ function wc_get_orders( $args ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $date_before && $date_after ) {
|
if ( $date_before && $date_after ) {
|
||||||
$args['date_created'] = $date_before . '...' . $date_after;
|
$args['date_created'] = $date_after . '...' . $date_before;
|
||||||
} elseif ( $date_before ) {
|
} elseif ( $date_before ) {
|
||||||
$args['date_created'] = '<' . $date_before;
|
$args['date_created'] = '<' . $date_before;
|
||||||
} elseif ( $date_after ) {
|
} elseif ( $date_after ) {
|
||||||
|
|
|
@ -236,6 +236,12 @@ class WC_Tests_Order_Functions extends WC_Unit_Test_Case {
|
||||||
sort( $orders );
|
sort( $orders );
|
||||||
$this->assertEquals( $expected, $orders );
|
$this->assertEquals( $expected, $orders );
|
||||||
|
|
||||||
|
$orders = wc_get_orders( array( 'date_before' => '2017-01-15', 'date_after' => '2015-01-01 00:00:00', 'return' => 'ids' ) );
|
||||||
|
$expected = array( $order_1, $order_2, $order_3 );
|
||||||
|
sort( $expected );
|
||||||
|
sort( $orders );
|
||||||
|
$this->assertEquals( $expected, $orders );
|
||||||
|
|
||||||
$order1->delete();
|
$order1->delete();
|
||||||
$order2->delete();
|
$order2->delete();
|
||||||
$order3->delete();
|
$order3->delete();
|
||||||
|
|
Loading…
Reference in New Issue