Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes

CustomerHistory::get_excluded_statuses_sqlprivateWC 1.0

Get the SQL fragment for excluded order statuses.

Method of the class: CustomerHistory{}

No Hooks.

Returns

String. SQL IN clause, e.g. ( 'auto-draft','trash','wc-pending','wc-failed',... ), or empty string if no statuses are excluded.

Usage

// private - for code of main (parent) class only
$result = $this->get_excluded_statuses_sql(): string;

CustomerHistory::get_excluded_statuses_sql() code WC 11.0.1

private function get_excluded_statuses_sql(): string {
	global $wpdb;

	$excluded_statuses = $this->get_excluded_statuses();

	if ( empty( $excluded_statuses ) ) {
		return '';
	}

	$prefixed = array_map(
		function ( $status ) {
			$status = sanitize_title( $status );
			return 'auto-draft' === $status || 'trash' === $status ? $status : 'wc-' . $status;
		},
		$excluded_statuses
	);

	$placeholders = implode( ',', array_fill( 0, count( $prefixed ), '%s' ) );

	// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- $placeholders is a safe string of %s tokens.
	return $wpdb->prepare( "( $placeholders )", $prefixed );
}