Merge pull request #23451 from woocommerce/fix/23387
Array handling in `get_catalog_ordering_args` to prevent notices
This commit is contained in:
commit
2810e6cdf3
|
@ -454,8 +454,9 @@ class WC_Query {
|
|||
$order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order;
|
||||
}
|
||||
|
||||
$orderby = strtolower( $orderby );
|
||||
$order = strtoupper( $order );
|
||||
// Convert to correct format.
|
||||
$orderby = strtolower( is_array( $orderby ) ? (string) current( $orderby ) : (string) $orderby );
|
||||
$order = strtoupper( is_array( $order ) ? (string) current( $order ) : (string) $order );
|
||||
$args = array(
|
||||
'orderby' => $orderby,
|
||||
'order' => ( 'DESC' === $order ) ? 'DESC' : 'ASC',
|
||||
|
|
|
@ -282,6 +282,20 @@ class WC_Tests_WC_Query extends WC_Unit_Test_Case {
|
|||
'meta_key' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'orderby' => array(
|
||||
'price',
|
||||
'date',
|
||||
),
|
||||
'order' => array(
|
||||
'DESC',
|
||||
),
|
||||
'expected' => array(
|
||||
'orderby' => 'price',
|
||||
'order' => 'DESC',
|
||||
'meta_key' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $data as $test ) {
|
||||
|
|
Loading…
Reference in New Issue