Automattic\WooCommerce\Admin\API\Reports\Coupons

DataStore::add_sql_query_params()protectedWC 1.0

Updates the database query with parameters used for Products report: categories and order status.

Method of the class: DataStore{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->add_sql_query_params( $query_args );
$query_args(array) (required)
Query arguments supplied by the user.

DataStore::add_sql_query_params() code WC 7.3.0

protected function add_sql_query_params( $query_args ) {
	global $wpdb;
	$order_coupon_lookup_table = self::get_db_table_name();

	$this->add_time_period_sql_params( $query_args, $order_coupon_lookup_table );
	$this->get_limit_sql_params( $query_args );

	$included_coupons = $this->get_included_coupons( $query_args, 'coupons' );
	if ( $included_coupons ) {
		$this->subquery->add_sql_clause( 'where', "AND {$order_coupon_lookup_table}.coupon_id IN ({$included_coupons})" );

		$this->add_order_by_params( $query_args, 'outer', 'default_results.coupon_id' );
	} else {
		$this->add_order_by_params( $query_args, 'inner', "{$order_coupon_lookup_table}.coupon_id" );
	}

	$this->add_order_status_clause( $query_args, $order_coupon_lookup_table, $this->subquery );
}