WC_Order_Item_Meta::get_formatted_legacy()
Return an array of formatted item meta in format e.g. Handles @deprecated args.
Метод класса: WC_Order_Item_Meta{}
Хуки из метода
Возвращает
Массив
.
Использование
$WC_Order_Item_Meta = new WC_Order_Item_Meta(); $WC_Order_Item_Meta->get_formatted_legacy( $hideprefix );
- $hideprefix(строка)
- Hide prefix.
По умолчанию: '_'
Код WC_Order_Item_Meta::get_formatted_legacy() WC Order Item Meta::get formatted legacy WC 9.3.1
public function get_formatted_legacy( $hideprefix = '_' ) { if ( ! wp_doing_ajax() ) { wc_deprecated_argument( 'WC_Order_Item_Meta::get_formatted', '2.4', 'Item Meta Data is being called with legacy arguments' ); } $formatted_meta = array(); foreach ( $this->meta as $meta_key => $meta_values ) { if ( empty( $meta_values ) || ( ! empty( $hideprefix ) && substr( $meta_key, 0, 1 ) === $hideprefix ) ) { continue; } foreach ( (array) $meta_values as $meta_value ) { // Skip serialised meta. if ( is_serialized( $meta_value ) ) { continue; } $attribute_key = urldecode( str_replace( 'attribute_', '', $meta_key ) ); // If this is a term slug, get the term's nice name. if ( taxonomy_exists( $attribute_key ) ) { $term = get_term_by( 'slug', $meta_value, $attribute_key ); if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) { $meta_value = $term->name; } } // Unique key required. $formatted_meta_key = $meta_key; $loop = 0; while ( isset( $formatted_meta[ $formatted_meta_key ] ) ) { $loop ++; $formatted_meta_key = $meta_key . '-' . $loop; } $formatted_meta[ $formatted_meta_key ] = array( 'key' => $meta_key, 'label' => wc_attribute_label( $attribute_key, $this->product ), 'value' => apply_filters( 'woocommerce_order_item_display_meta_value', $meta_value, $this->meta, $this->item ), ); } } return $formatted_meta; }