diff --git a/includes/abstracts/abstract-wc-data.php b/includes/abstracts/abstract-wc-data.php index 2cb1b3b37f1..9c436791cf3 100644 --- a/includes/abstracts/abstract-wc-data.php +++ b/includes/abstracts/abstract-wc-data.php @@ -594,11 +594,8 @@ abstract class WC_Data { } } - $raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta( $this ); - if ( $cache_loaded ) { - // Filter the raw meta data again, in case we cached in an earlier version where filter conditions were different. - $raw_meta_data = $this->data_store->filter_raw_data( $this, $raw_meta_data ); - } + // We filter the raw meta data again when loading from cache, in case we cached in an earlier version where filter conditions were different. + $raw_meta_data = $cache_loaded ? $this->data_store->filter_raw_meta_data( $this, $cached_meta ) : $this->data_store->read_meta( $this ); if ( $raw_meta_data ) { foreach ( $raw_meta_data as $meta ) { diff --git a/includes/data-stores/class-wc-data-store-wp.php b/includes/data-stores/class-wc-data-store-wp.php index f544ca800bc..c94907bd04d 100644 --- a/includes/data-stores/class-wc-data-store-wp.php +++ b/includes/data-stores/class-wc-data-store-wp.php @@ -94,7 +94,7 @@ class WC_Data_Store_WP { $object->get_id() ) ); - return $this->filter_raw_data( $object, $raw_meta_data ); + return $this->filter_raw_meta_data( $object, $raw_meta_data ); } /** @@ -107,7 +107,7 @@ class WC_Data_Store_WP { * * @return mixed|void */ - public function filter_raw_data( &$object, $raw_meta_data ) { + public function filter_raw_meta_data( &$object, $raw_meta_data ) { $this->internal_meta_keys = array_merge( array_map( array( $this, 'prefix_key' ), $object->get_data_keys() ), $this->internal_meta_keys ); $meta_data = array_filter( $raw_meta_data, array( $this, 'exclude_internal_meta_keys' ) ); return apply_filters( "woocommerce_data_store_wp_{$this->meta_type}_read_meta", $meta_data, $object, $this );