Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableQuery::process_orderby()privateWC 1.0

Generates the ORDER BY clause.

Метод класса: OrdersTableQuery{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->process_orderby(): void;

Код OrdersTableQuery::process_orderby() WC 8.6.1

private function process_orderby(): void {
	// 'order' and 'orderby' vars.
	$this->args['order'] = $this->sanitize_order( $this->args['order'] ?? '' );
	$this->sanitize_order_orderby();

	$orderby = $this->args['orderby'];

	if ( 'none' === $orderby ) {
		$this->orderby = '';
		return;
	}

	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;
	}

	$meta_orderby_keys = $this->meta_query ? $this->meta_query->get_orderby_keys() : array();

	$orderby_array = array();
	foreach ( $this->args['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;
}