meta = $item_meta; $this->product = $product; } /** * Display meta in a formatted list * * @access public * @param bool $flat (default: false) * @param bool $return (default: false) * @param string $hideprefix (default: _) * @return string */ public function display( $flat = false, $return = false, $hideprefix = '_' ) { if ( ! empty( $this->meta ) ) { $meta_list = array(); foreach ( $this->meta as $meta_key => $meta_values ) { if ( empty( $meta_values ) || ( ! empty( $hideprefix ) && substr( $meta_key, 0, 1 ) == $hideprefix ) ) continue; foreach( $meta_values as $meta_value ) { // Skip serialised meta if ( is_serialized( $meta_value ) ) continue; // If this is a term slug, get the term's nice name if ( taxonomy_exists( esc_attr( str_replace( 'attribute_', '', $meta_key ) ) ) ) { $term = get_term_by('slug', $meta_value, esc_attr( str_replace( 'attribute_', '', $meta_key ) ) ); if ( ! is_wp_error( $term ) && $term->name ) $meta_value = $term->name; // If we have a product, and its not a term, try to find its non-sanitized name } elseif ( $this->product ) { $product_attributes = $this->product->get_attributes(); if ( isset( $product_attributes[ str_replace( 'attribute_', '', urldecode( $meta_key ) ) ] ) ) { $meta_key = wc_attribute_label( $product_attributes[ str_replace( 'attribute_', '', urldecode( $meta_key ) ) ]['name'] ); } } if ( $flat ) $meta_list[] = esc_attr( wc_attribute_label( str_replace( 'attribute_', '', $meta_key ) ) . ': ' . apply_filters( 'woocommerce_order_item_display_meta_value', $meta_value ) ); else $meta_list[] = '