WordPress at Your Fingertips
function is not described


DataStore::add_order_by_clause() protected WC 1.0

Add order by SQL clause if included in query.

{} It's a method of the class: DataStore{}

No Hooks.


String. Order by clause.


// protected - for code of main (parent) or child class
$result = $this->add_order_by_clause( $query_args, $sql_query );
$query_args(array) (required)
Parameters supplied by the user.
$sql_query(SqlQuery) (required) (passed by reference — &)
Query object.

Code of DataStore::add_order_by_clause() WC 6.1.0

protected function add_order_by_clause( $query_args, &$sql_query ) {
	$order_by_clause = '';

	$sql_query->clear_sql_clause( array( 'order_by' ) );
	if ( isset( $query_args['orderby'] ) ) {
		$order_by_clause = $this->normalize_order_by( $query_args['orderby'] );
		$sql_query->add_sql_clause( 'order_by', $order_by_clause );

	// Return ORDER BY clause to allow adding the sort field(s) to query via a JOIN.
	return $order_by_clause;