WordPress at a glance
function is not described

wc_format_stock_for_display() WC 3.0.0

Format the stock amount ready for display based on settings.

No Hooks.

Return

String. Nothing.

Usage

wc_format_stock_for_display( $product );
$product(WC_Product) (required)
Product object for which the stock you need to format.

Changelog

Since 3.0.0 Introduced.

Code of wc_format_stock_for_display() WC 5.3.0

<?php
function wc_format_stock_for_display( $product ) {
	$display      = __( 'In stock', 'woocommerce' );
	$stock_amount = $product->get_stock_quantity();

	switch ( get_option( 'woocommerce_stock_format' ) ) {
		case 'low_amount':
			if ( $stock_amount <= wc_get_low_stock_amount( $product ) ) {
				/* translators: %s: stock amount */
				$display = sprintf( __( 'Only %s left in stock', 'woocommerce' ), wc_format_stock_quantity_for_display( $stock_amount, $product ) );
			}
			break;
		case '':
			/* translators: %s: stock amount */
			$display = sprintf( __( '%s in stock', 'woocommerce' ), wc_format_stock_quantity_for_display( $stock_amount, $product ) );
			break;
	}

	if ( $product->backorders_allowed() && $product->backorders_require_notification() ) {
		$display .= ' ' . __( '(can be backordered)', 'woocommerce' );
	}

	return $display;
}