Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::update_address_index_meta()privateWC 1.0

Helper function to update billing and shipping address metadata.

Method of the class: OrdersTableDataStore{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->update_address_index_meta( $order, $changes );
$order(\WC_Abstract_Order) (required)
Order Object.
$changes(array) (required)
Array of changes.

OrdersTableDataStore::update_address_index_meta() code WC 9.3.3

private function update_address_index_meta( $order, $changes ) {
	// If address changed, store concatenated version to make searches faster.
	foreach ( array( 'billing', 'shipping' ) as $address_type ) {
		$index_meta_key = "_{$address_type}_address_index";

		if ( isset( $changes[ $address_type ] ) || ( is_a( $order, 'WC_Order' ) && empty( $order->get_meta( $index_meta_key ) ) ) ) {
			$order->update_meta_data( $index_meta_key, implode( ' ', $order->get_address( $address_type ) ) );
		}
	}
}