Merge pull request #17017 from woocommerce/fix/17003

Handle WC_Meta_Data in get_data() and API
This commit is contained in:
Claudiu Lodromanean 2017-10-02 09:19:45 -07:00 committed by GitHub
commit d3d782c85c
2 changed files with 12 additions and 5 deletions

View File

@ -248,13 +248,12 @@ abstract class WC_Data {
* Filter null meta values from array.
*
* @since 3.0.0
*
* @param mixed $meta
*
* @param mixed $meta Meta value to check.
* @return bool
*/
protected function filter_null_meta( $meta ) {
return ! is_null( $meta->value );
$meta = (array) $meta;
return ! is_null( $meta['value'] );
}
/**
@ -265,7 +264,7 @@ abstract class WC_Data {
*/
public function get_meta_data() {
$this->maybe_read_meta_data();
return array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) );
return array_filter( wc_list_pluck( $this->meta_data, 'get_data' ), array( $this, 'filter_null_meta' ) );
}
/**

View File

@ -101,4 +101,12 @@ class WC_Meta_Data {
return $changes;
}
/**
* Return all data as an array.
*
* @return array
*/
public function get_data() {
return $this->data;
}
}