Automattic\WooCommerce\Internal\DataStores\Orders
LegacyDataHandler::limit_hpos_update_to_props()
Filters a set of HPOS row updates to those matching a specific set of order properties. Called via the woocommerce_orders_table_datastore_db_rows_for_order in backfill_order_to_datastore.
Метод класса: LegacyDataHandler{}
Хуков нет.
Возвращает
Массив
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->limit_hpos_update_to_props( $rows, $props );
- $rows(массив) (обязательный)
- Details for the db update.
- $props(string[]) (обязательный)
- Order property names.
Заметки
Код LegacyDataHandler::limit_hpos_update_to_props() LegacyDataHandler::limit hpos update to props WC 9.7.1
private function limit_hpos_update_to_props( array $rows, array $props ) { // Determine HPOS columns corresponding to the props in the $props array. $allowed_columns = array(); foreach ( $this->data_store->get_all_order_column_mappings() as &$mapping ) { foreach ( $mapping as $column_name => &$column_data ) { if ( ! isset( $column_data['name'] ) || ! in_array( $column_data['name'], $props, true ) ) { continue; } $allowed_columns[ $column_data['name'] ] = $column_name; } } foreach ( $rows as $i => &$db_update ) { // Prevent accidental update of another prop by limiting columns to explicitly requested props. if ( ! array_intersect_key( $db_update['data'], array_flip( $allowed_columns ) ) ) { unset( $rows[ $i ] ); continue; } $allowed_column_names_with_ids = array_merge( $allowed_columns, array( 'id', 'order_id', 'address_type' ) ); $db_update['data'] = array_intersect_key( $db_update['data'], array_flip( $allowed_column_names_with_ids ) ); $db_update['format'] = array_intersect_key( $db_update['format'], array_flip( $allowed_column_names_with_ids ) ); } return $rows; }