Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::filter_raw_meta_data()
For post based data stores, this was used to filter internal meta data. For custom tables, technically there is no internal meta data, (i.e. we store all core data as properties for the order, and not in meta data). So this method is a no-op.
Except that some meta such as billing_address_index and shipping_address_index are infact stored in meta data, so we need to filter those out.
However, declaring $internal_meta_keys is still required so that our backfill and other comparison checks works as expected.
Method of the class: OrdersTableDataStore{}
No Hooks.
Return
Array
. Filtered meta data.
Usage
$OrdersTableDataStore = new OrdersTableDataStore(); $OrdersTableDataStore->filter_raw_meta_data( $object, $raw_meta_data );
- $object(\WC_Data) (required) (passed by reference — &)
- Object to filter meta data for.
- $raw_meta_data(array) (required)
- Raw meta data.
OrdersTableDataStore::filter_raw_meta_data() OrdersTableDataStore::filter raw meta data code WC 9.3.3
public function filter_raw_meta_data( &$object, $raw_meta_data ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound $filtered_meta_data = parent::filter_raw_meta_data( $object, $raw_meta_data ); $allowed_keys = array( '_billing_address_index', '_shipping_address_index', ); $allowed_meta = array_filter( $raw_meta_data, function ( $meta ) use ( $allowed_keys ) { return in_array( $meta->meta_key, $allowed_keys, true ); } ); return array_merge( $allowed_meta, $filtered_meta_data ); }