WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wc_format_stock_for_display() WC 3.0.0

Format the stock amount ready for display based on settings.

Хуков нет.

Возвращает

Строку.

Использование

wc_format_stock_for_display( $product );
$product(WC_Product) (обязательный)
Product object for which the stock you need to format.

Список изменений

С версии 3.0.0 Введена.

Код wc format stock for display: woocommerce/includes/wc-formatting-functions.php WC 4.3.2

<?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 <= get_option( 'woocommerce_notify_low_stock_amount' ) ) {
				/* 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;
}