Automattic\WooCommerce\Internal\Admin\Orders
ListTable::set_order_args
Updates the WC Order Query arguments as needed to support orderable columns.
Method of the class: ListTable{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->set_order_args();
ListTable::set_order_args() ListTable::set order args code WC 10.3.3
private function set_order_args() {
$sortable = $this->get_sortable_columns();
$field = sanitize_text_field( wp_unslash( $_GET['orderby'] ?? '' ) );
$direction = strtoupper( sanitize_text_field( wp_unslash( $_GET['order'] ?? '' ) ) );
if ( ! in_array( $field, $sortable, true ) ) {
$this->order_query_args['orderby'] = 'date';
$this->order_query_args['order'] = 'DESC';
return;
}
$this->order_query_args['orderby'] = $field;
$this->order_query_args['order'] = in_array( $direction, array( 'ASC', 'DESC' ), true ) ? $direction : 'ASC';
}