wc_format_weight()
Format a weight for display.
Hooks from the function
Return
String
.
Usage
wc_format_weight( $weight );
- $weight(float) (required)
- Weight.
Changelog
Since 3.0.0 | Introduced. |
wc_format_weight() wc format weight code WC 9.6.1
function wc_format_weight( $weight ) { $weight_string = wc_format_localized_decimal( $weight ); if ( ! empty( $weight_string ) ) { $weight_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit' ) ); $weight_string = sprintf( // translators: 1. A formatted number; 2. A label for a weight unit of measure. E.g. 2.72 kg. _x( '%1$s %2$s', 'formatted weight', 'woocommerce' ), $weight_string, $weight_label ); } else { $weight_string = __( 'N/A', 'woocommerce' ); } return apply_filters( 'woocommerce_format_weight', $weight_string, $weight ); }