Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::get_order_table_select_statement()
Helper method to generate combined select statement.
Method of the class: OrdersTableDataStore{}
No Hooks.
Return
String
. Select SQL statement to fetch order.
Usage
// private - for code of main (parent) class only $result = $this->get_order_table_select_statement();
OrdersTableDataStore::get_order_table_select_statement() OrdersTableDataStore::get order table select statement code WC 9.7.1
private function get_order_table_select_statement() { $order_table = $this::get_orders_table_name(); $order_table_alias = $this->get_order_table_alias(); $billing_address_table_alias = $this->get_address_table_alias( 'billing' ); $shipping_address_table_alias = $this->get_address_table_alias( 'shipping' ); $op_data_table_alias = $this->get_op_table_alias(); $billing_address_clauses = $this->join_billing_address_table_to_order_query( $order_table_alias, $billing_address_table_alias ); $shipping_address_clauses = $this->join_shipping_address_table_to_order_query( $order_table_alias, $shipping_address_table_alias ); $operational_data_clauses = $this->join_operational_data_table_to_order_query( $order_table_alias, $op_data_table_alias ); /** * We fully spell out address table columns because they have duplicate columns for billing and shipping and would be overwritten if we don't spell them out. There is not such duplication in the operational data table and orders table, so select with `alias`.* is fine. * We do spell ID columns manually, as they are duplicate. */ return " SELECT $order_table_alias.id as o_id, $op_data_table_alias.id as p_id, $order_table_alias.*, {$billing_address_clauses['select']}, {$shipping_address_clauses['select']}, $op_data_table_alias.* FROM $order_table $order_table_alias LEFT JOIN {$billing_address_clauses['join']} LEFT JOIN {$shipping_address_clauses['join']} LEFT JOIN {$operational_data_clauses['join']} "; }