WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::add_product_names_to_message() private WC 1.0

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

{} It's a method of the class: CartController{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->add_product_names_to_message( $singular, $plural, $items );
$singular(string) (required)
The message to use when only one product is in the list.
$plural(string) (required)
The message to use when more than one product is in the list.
$items(array) (required)
The list of cart items whose names should be inserted into the message.

Code of CartController::add_product_names_to_message() WC 5.8.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 )
	);
}