wc_display_item_meta

Display item meta data.

Description

(string|void) wc_display_item_meta( (WC_Item) $item, (array) $args = array() ); 

Returns (string|void)

Parameters (2)

0. $item (WC_Item)
The item.
1. $args — Optional. (array) => array()
The args.

Usage

  1. if ( !function_exists( 'wc_display_item_meta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4. // The item. 
  5. $item = null; 
  6.  
  7. // The args. 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_display_item_meta($item, $args); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function wc_display_item_meta( $item, $args = array() ) { 
  2. $strings = array(); 
  3. $html = ''; 
  4. $args = wp_parse_args( $args, array( 
  5. 'before' => '<ul class="wc-item-meta"><li>',  
  6. 'after' => '</li></ul>',  
  7. 'separator' => '</li><li>',  
  8. 'echo' => true,  
  9. 'autop' => false,  
  10. ) ); 
  11.  
  12. foreach ( $item->get_formatted_meta_data() as $meta_id => $meta ) { 
  13. $value = $args['autop'] ? wp_kses_post( $meta->display_value ) : wp_kses_post( make_clickable( trim( strip_tags( $meta->display_value ) ) ) ); 
  14. $strings[] = '<strong class="wc-item-meta-label">' . wp_kses_post( $meta->display_key ) . ':</strong> ' . $value; 
  15.  
  16. if ( $strings ) { 
  17. $html = $args['before'] . implode( $args['separator'], $strings ) . $args['after']; 
  18.  
  19. $html = apply_filters( 'woocommerce_display_item_meta', $html, $item, $args ); 
  20.  
  21. if ( $args['echo'] ) { 
  22. echo $html; 
  23. } else { 
  24. return $html;