WC_Data_Store_WP::read_meta( WC_Data $object )
Returns an array of meta for an object.
Description Description
Parameters Parameters
- $object
-
(Required) WC_Data object.
Return Return
(array)
Source Source
File: includes/data-stores/class-wc-data-store-wp.php
public function read_meta( &$object ) {
global $wpdb;
$db_info = $this->get_db_info();
$raw_meta_data = $wpdb->get_results(
$wpdb->prepare(
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
"SELECT {$db_info['meta_id_field']} as meta_id, meta_key, meta_value
FROM {$db_info['table']}
WHERE {$db_info['object_id_field']} = %d
ORDER BY {$db_info['meta_id_field']}",
// phpcs:enable
$object->get_id()
)
);
$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 );
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |