Automattic\WooCommerce\StoreApi\Utilities

CartController::add_product_names_to_message()privateWC 1.0

Generates the error message for out of stock products and adds product names to it.

Метод класса: CartController{}

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->add_product_names_to_message( $singular, $plural, $items );
$singular(строка) (обязательный)
The message to use when only one product is in the list.
$plural(строка) (обязательный)
The message to use when more than one product is in the list.
$items(массив) (обязательный)
The list of cart items whose names should be inserted into the message.

Код CartController::add_product_names_to_message() WC 8.7.0

private function add_product_names_to_message( $singular, $plural, $items ) {
	$product_names = wc_list_pluck( $items, 'getProductName' );
	$message       = ( count( $items ) > 1 ) ? $plural : $singular;
	return sprintf(
		$message,
		ArrayUtils::natural_language_join( $product_names, true )
	);
}