WordPress at Your Fingertips
function is not described


DataStore::add_order_status_clause() protected WC 1.0

Add order status SQL clauses if included in query.

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

No Hooks.


null. Nothing.


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

Code of DataStore::add_order_status_clause() WC 6.1.0

protected function add_order_status_clause( $query_args, $table_name, &$sql_query ) {
	global $wpdb;
	$order_status_filter = $this->get_status_subquery( $query_args );
	if ( $order_status_filter ) {
		$sql_query->add_sql_clause( 'join', "JOIN {$wpdb->prefix}wc_order_stats ON {$table_name}.order_id = {$wpdb->prefix}wc_order_stats.order_id" );
		$sql_query->add_sql_clause( 'where', "AND ( {$order_status_filter} )" );