Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableStatusUnionQuery::extract_types_and_statuses
Extracts the queried order types and statuses, or NULL when they don't form a rewritable set: the 'type' and 'status' args must both be set and contain only non-empty strings, cover at least two statuses (a single status is already served by the type_status_date index), and stay within the branch cap.
Method of the class: OrdersTableStatusUnionQuery{}
No Hooks.
Returns
Array[]|null. Array of [ types, statuses ] (each a list of unique strings), or NULL when ineligible.
Usage
// private - for code of main (parent) class only $result = $this->extract_types_and_statuses(): ?array;
OrdersTableStatusUnionQuery::extract_types_and_statuses() OrdersTableStatusUnionQuery::extract types and statuses code WC 11.0.0
private function extract_types_and_statuses(): ?array {
if ( ! $this->query->arg_isset( 'type' ) || ! $this->query->arg_isset( 'status' ) ) {
return null;
}
$types = array_values( array_unique( (array) $this->query->get( 'type' ) ) );
$statuses = array_values( array_unique( (array) $this->query->get( 'status' ) ) );
foreach ( array_merge( $types, $statuses ) as $value ) {
if ( ! is_string( $value ) || '' === $value ) {
return null;
}
}
if ( count( $statuses ) < 2 || ( count( $types ) * count( $statuses ) ) > self::MAX_BRANCHES ) {
return null;
}
return array( $types, $statuses );
}