WC_REST_Products_V4_Controller::exclude_product_statusespublicWC 1.0

Exclude product statuses from the query.

Method of the class: WC_REST_Products_V4_Controller{}

No Hooks.

Returns

String.

Usage

$WC_REST_Products_V4_Controller = new WC_REST_Products_V4_Controller();
$WC_REST_Products_V4_Controller->exclude_product_statuses( $where );
$where(string) (required)
Where clause used to search posts.

WC_REST_Products_V4_Controller::exclude_product_statuses() code WC 10.3.6

public function exclude_product_statuses( $where ) {
	if ( ! empty( $this->exclude_status ) && is_array( $this->exclude_status ) ) {
		global $wpdb;

		$not_in = array();
		foreach ( $this->exclude_status as $status_to_exclude ) {
			$not_in[] = $wpdb->prepare( '%s', $status_to_exclude );
		}

		$not_in = join( ', ', $not_in );
		return $where . " AND $wpdb->posts.post_status NOT IN ( $not_in )";
	}

	return $where;
}