Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableMetaQuery::get_orderby_clause_for_key()
Returns an SQL fragment for the given meta_query key that can be used in an ORDER BY clause. Call {@see 'get_orderby_keys'} to obtain a list of valid keys.
Метод класса: OrdersTableMetaQuery{}
Хуков нет.
Возвращает
Строку
.
Использование
$OrdersTableMetaQuery = new OrdersTableMetaQuery(); $OrdersTableMetaQuery->get_orderby_clause_for_key( $key ): string;
- $key(строка) (обязательный)
- The key name.
Список изменений
С версии 7.4 | Введена. |
Код OrdersTableMetaQuery::get_orderby_clause_for_key() OrdersTableMetaQuery::get orderby clause for key WC 9.4.2
public function get_orderby_clause_for_key( string $key ): string { $clause = false; if ( isset( $this->flattened_clauses[ $key ] ) ) { $clause = $this->flattened_clauses[ $key ]; } else { $first_clause = reset( $this->flattened_clauses ); if ( $first_clause && ! empty( $first_clause['key'] ) ) { if ( 'meta_value_num' === $key ) { return "{$first_clause['alias']}.meta_value+0"; } if ( 'meta_value' === $key || $first_clause['key'] === $key ) { $clause = $first_clause; } } } if ( ! $clause ) { // translators: %s is a meta_query key. throw new \Exception( sprintf( __( 'Invalid meta_query clause key: %s.', 'woocommerce' ), $key ) ); } return "CAST({$clause['alias']}.meta_value AS {$clause['cast']})"; }