WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта с помощью браузерных PUSH уведомлений
функция не описана

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::get_error_message_for_stock_exception_type() private WC 1.0

Takes a string describing the type of stock extension, whether there is a single product or multiple products causing this exception and returns an appropriate error message.

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

Хуков нет.

Возвращает

Строку. Ничего.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_error_message_for_stock_exception_type( $exception_type, $singular_or_plural );
$exception_type(строка) (обязательный)
The type of exception encountered.
$singular_or_plural(строка) (обязательный)
Whether to get the error message for a single product or multiple.

Код CartController::get_error_message_for_stock_exception_type() WC 5.3.0

<?php
private function get_error_message_for_stock_exception_type( $exception_type, $singular_or_plural ) {
	$stock_error_messages = [
		'out_of_stock'         => [
			/* translators: %s: product name. */
			'singular' => __(
				'%s is out of stock and cannot be purchased. Please remove it from your cart.',
				'woocommerce'
			),
			/* translators: %s: product names. */
			'plural'   => __(
				'%s are out of stock and cannot be purchased. Please remove them from your cart.',
				'woocommerce'
			),
		],
		'not_purchasable'      => [
			/* translators: %s: product name. */
			'singular' => __(
				'%s cannot be purchased.  Please remove it from your cart.',
				'woocommerce'
			),
			/* translators: %s: product names. */
			'plural'   => __(
				'%s cannot be purchased. Please remove them from your cart.',
				'woocommerce'
			),
		],
		'too_many_in_cart'     => [
			/* translators: %s: product names. */
			'singular' => __(
				'There are too many %s in the cart. Only 1 can be purchased. Please reduce the quantity in your cart.',
				'woocommerce'
			),
			/* translators: %s: product names. */
			'plural'   => __(
				'There are too many %s in the cart. Only 1 of each can be purchased. Please reduce the quantities in your cart.',
				'woocommerce'
			),
		],
		'partial_out_of_stock' => [
			/* translators: %s: product names. */
			'singular' => __(
				'There is not enough %s in stock. Please reduce the quantity in your cart.',
				'woocommerce'
			),
			/* translators: %s: product names. */
			'plural'   => __(
				'There are not enough %s in stock. Please reduce the quantities in your cart.',
				'woocommerce'
			),
		],
	];

	if (
		isset( $stock_error_messages[ $exception_type ] ) &&
		isset( $stock_error_messages[ $exception_type ][ $singular_or_plural ] )
	) {
		return $stock_error_messages[ $exception_type ][ $singular_or_plural ];
	}

	return __( 'There was an error with an item in your cart.', 'woocommerce' );
}