Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats

DataStore::update_sql_query_params()protectedWC 1.0

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

{} Это метод класса: DataStore{}

Хуков нет.

Возвращает

null. Ничего.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->update_sql_query_params( $query_args );
$query_args(массив) (обязательный)
Query arguments supplied by the user.

Код DataStore::update_sql_query_params() WC 6.9.4

protected function update_sql_query_params( $query_args ) {
	global $wpdb;

	$clauses = array(
		'where' => '',
		'join'  => '',
	);

	$order_coupon_lookup_table = self::get_db_table_name();

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

	$order_status_filter = $this->get_status_subquery( $query_args );
	if ( $order_status_filter ) {
		$clauses['join']  .= " JOIN {$wpdb->prefix}wc_order_stats ON {$order_coupon_lookup_table}.order_id = {$wpdb->prefix}wc_order_stats.order_id";
		$clauses['where'] .= " AND ( {$order_status_filter} )";
	}

	$this->add_time_period_sql_params( $query_args, $order_coupon_lookup_table );
	$this->add_intervals_sql_params( $query_args, $order_coupon_lookup_table );
	$clauses['where_time'] = $this->get_sql_clause( 'where_time' );

	$this->interval_query->add_sql_clause( 'limit', $this->get_sql_clause( 'limit' ) );
	$this->interval_query->add_sql_clause( 'order_by', $this->get_sql_clause( 'order_by' ) );
	$this->interval_query->add_sql_clause( 'select', $this->get_sql_clause( 'select' ) );
	$this->interval_query->add_sql_clause( 'select', 'AS time_interval' );

	foreach ( array( 'join', 'where_time', 'where' ) as $clause ) {
		$this->interval_query->add_sql_clause( $clause, $clauses[ $clause ] );
		$this->total_query->add_sql_clause( $clause, $clauses[ $clause ] );
	}
}