WC_REST_Orders_V2_Controller::merge_meta_item_with_formatted_meta_display_attributes()privateWC 1.0

Merge the $formatted_meta_data display_key and display_value attribute values into the corresponding WC_Meta_Data. Returns the merged array.

Method of the class: WC_REST_Orders_V2_Controller{}

No Hooks.




// private - for code of main (parent) class only
$result = $this->merge_meta_item_with_formatted_meta_display_attributes( $meta_item, $formatted_meta_data );
$meta_item(WC_Meta_Data) (required)
An object from WC_Order_Item::get_meta_data().
$formatted_meta_data(array) (required)
An object result from WC_Order_Item::get_all_formatted_meta_data. The keys are the IDs of WC_Meta_Data.

WC_REST_Orders_V2_Controller::merge_meta_item_with_formatted_meta_display_attributes() code WC 8.9.0

private function merge_meta_item_with_formatted_meta_display_attributes( $meta_item, $formatted_meta_data ) {
	$result = array(
		'id'            => $meta_item->id,
		'key'           => $meta_item->key,
		'value'         => $meta_item->value,
		'display_key'   => $meta_item->key,   // Default to original key, in case a formatted key is not available.
		'display_value' => $meta_item->value, // Default to original value, in case a formatted value is not available.

	if ( array_key_exists( $meta_item->id, $formatted_meta_data ) ) {
		$formatted_meta_item = $formatted_meta_data[ $meta_item->id ];

		$result['display_key']   = wc_clean( $formatted_meta_item->display_key );
		$result['display_value'] = wc_clean( $formatted_meta_item->display_value );

	return $result;