wc_format_dimensions

Format dimensions for display.

Description

(string) wc_format_dimensions( (array) $dimensions ); 

Returns (string)

Parameters (1)

0. $dimensions (array)
Array of dimensions.

Usage

  1. if ( !function_exists( 'wc_format_dimensions' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // Array of dimensions. 
  5. $dimensions = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_format_dimensions($dimensions); 
  9.  

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_format_dimensions( $dimensions ) { 
  2. $dimension_string = implode( ' x ', array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) ) ); 
  3.  
  4. if ( ! empty( $dimension_string ) ) { 
  5. $dimension_string .= ' ' . get_option( 'woocommerce_dimension_unit' ); 
  6. } else { 
  7. $dimension_string = __( 'N/A', woocommerce ); 
  8.  
  9. return apply_filters( 'woocommerce_format_dimensions', $dimension_string, $dimensions );