Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableQuery::process_orders_table_query_args
Processes fields related to the orders table.
Method of the class: OrdersTableQuery{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->process_orders_table_query_args(): void;
OrdersTableQuery::process_orders_table_query_args() OrdersTableQuery::process orders table query args code WC 10.7.0
private function process_orders_table_query_args(): void {
$this->sanitize_status();
$fields = array_filter(
array(
'id',
'status',
'type',
'currency',
'tax_amount',
'customer_id',
'billing_email',
'parent_order_id',
'payment_method',
'payment_method_title',
'transaction_id',
'ip_address',
'user_agent',
),
array( $this, 'arg_isset' )
);
foreach ( $fields as $arg_key ) {
$this->where[] = $this->where( $this->tables['orders'], $arg_key, '=', $this->args[ $arg_key ], $this->mappings['orders'][ $arg_key ]['type'] );
}
if ( $this->arg_isset( 'parent_exclude' ) ) {
$this->where[] = $this->where( $this->tables['orders'], 'parent_order_id', '!=', $this->args['parent_exclude'], 'int' );
}
if ( $this->arg_isset( 'exclude' ) ) {
$this->where[] = $this->where( $this->tables['orders'], 'id', '!=', $this->args['exclude'], 'int' );
}
// 'customer' is a very special field.
if ( $this->arg_isset( 'customer' ) ) {
$customer_query = $this->generate_customer_query( $this->args['customer'] );
if ( $customer_query ) {
$this->where[] = $customer_query;
}
}
// Handle total filtering with operators.
if ( $this->arg_isset( 'total_amount' ) ) {
$total_param = $this->args['total_amount'];
// If it's a simple number, convert to array format.
if ( is_numeric( $total_param ) ) {
$total_param = array(
'value' => $total_param,
'operator' => '=',
);
}
$total_query = $this->generate_total_query( (array) $total_param );
if ( $total_query ) {
$this->where[] = $total_query;
}
}
}