CartController::add_product_names_to_message()privateWC 1.0

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

Method of the class: CartController{}

No Hooks.


null. Nothing (null).


// 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.

CartController::add_product_names_to_message() code 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(
		ArrayUtils::natural_language_join( $product_names, true )