Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableStatusUnionQuery::extract_order_direction
Extracts the sort direction from the ORDER BY clause, or NULL when it isn't an ORDER BY on date_created_gmt alone (the only ordering the type_status_date index can satisfy within each branch).
Method of the class: OrdersTableStatusUnionQuery{}
No Hooks.
Returns
String|null. 'ASC', 'DESC', or NULL when ineligible.
Usage
// private - for code of main (parent) class only $result = $this->extract_order_direction( $orderby ): ?string;
- $orderby(string) (required)
- The ORDER BY clause, including the keyword.
OrdersTableStatusUnionQuery::extract_order_direction() OrdersTableStatusUnionQuery::extract order direction code WC 11.0.0
private function extract_order_direction( string $orderby ): ?string {
foreach ( array( 'ASC', 'DESC' ) as $direction ) {
if ( "ORDER BY {$this->orders_table}.date_created_gmt {$direction}" === $orderby ) {
return $direction;
}
}
return null;
}