Automattic\WooCommerce\StoreApi\Utilities

CartController::throw_default_product_exception()protectedWC 1.0

Default exception thrown when an item cannot be added to the cart.

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

Хуков нет.

Возвращает

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

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->throw_default_product_exception( $product );
$product(\WC_Product) (обязательный)
Product object associated with the cart item.

Код CartController::throw_default_product_exception() WC 8.7.0

protected function throw_default_product_exception( \WC_Product $product ) {
	throw new RouteException(
		'woocommerce_rest_product_not_purchasable',
		sprintf(
			/* translators: %s: product name */
			__( '"%s" is not available for purchase.', 'woocommerce' ),
			$product->get_name()
		),
		400
	);
}