OrdersTableDataStore::join_address_table_order_query()privateWC 1.0

Helper method to generate join and select query for address table.

Method of the class: OrdersTableDataStore{}

No Hooks.


Array. Select and join statements for address table.


// private - for code of main (parent) class only
$result = $this->join_address_table_order_query( $address_type, $order_table_alias, $address_table_alias );
$address_type(string) (required)
Type of address. Typically will be billing or shipping.
$order_table_alias(string) (required)
Alias of order table to use.
$address_table_alias(string) (required)
Alias for address table to use.

OrdersTableDataStore::join_address_table_order_query() code WC 7.1.0

private function join_address_table_order_query( $address_type, $order_table_alias, $address_table_alias ) {
	global $wpdb;
	$address_table    = $this::get_addresses_table_name();
	$column_props_map = 'billing' === $address_type ? $this->billing_address_column_mapping : $this->shipping_address_column_mapping;
	$clauses          = $this->generate_select_and_join_clauses( $order_table_alias, $address_table, $address_table_alias, $column_props_map );
	// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $clauses['join'] and $address_table_alias are hardcoded.
	$clauses['join'] = $wpdb->prepare(
		"{$clauses['join']} AND $address_table_alias.address_type = %s",

	// phpcs:enable
	return array(
		'select' => $clauses['select'],
		'join'   => $clauses['join'],