wc_format_weight

Format a weight for display.

Description

(string) wc_format_weight( (float) $weight ); 

Returns (string)

Parameters (1)

0. $weight (float)
The weight.

Usage

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

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_format_weight( $weight ) { 
  2. $weight_string = wc_format_localized_decimal( $weight ); 
  3.  
  4. if ( ! empty( $weight_string ) ) { 
  5. $weight_string .= ' ' . get_option( 'woocommerce_weight_unit' ); 
  6. } else { 
  7. $weight_string = __( 'N/A', woocommerce ); 
  8.  
  9. return apply_filters( 'woocommerce_format_weight', $weight_string, $weight );