Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableQuery::process_orderby
Generates the ORDER BY clause.
Метод класса: OrdersTableQuery{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->process_orderby(): void;
Код OrdersTableQuery::process_orderby() OrdersTableQuery::process orderby WC 10.7.0
private function process_orderby(): void {
// 'order' and 'orderby' vars.
$order = $this->sanitize_order( $this->args['order'] ?? '' );
$orderby = $this->sanitize_order_orderby( $this->args['orderby'] ?? 'none' );
// Set orderby to an empty array by default. This will also be used if sanitize_order_orderby recieved "none".
$this->orderby = array();
if ( 'include' === $orderby || 'post__in' === $orderby ) {
$ids = $this->args['id'] ?? $this->args['includes'];
if ( empty( $ids ) ) {
return;
}
$ids = array_map( 'absint', $ids );
$this->orderby = array( "FIELD( {$this->tables['orders']}.id, " . implode( ',', $ids ) . ' )' );
return;
}
if ( is_array( $orderby ) ) {
$meta_orderby_keys = $this->meta_query ? $this->meta_query->get_orderby_keys() : array();
$orderby_array = array();
foreach ( $orderby as $_orderby => $order ) {
if ( in_array( $_orderby, $meta_orderby_keys, true ) ) {
$_orderby = $this->meta_query->get_orderby_clause_for_key( $_orderby );
}
$orderby_array[] = "{$_orderby} {$order}";
}
$this->orderby = $orderby_array;
}
}