WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::throw_default_product_exception() protected WC 1.0

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

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

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->throw_default_product_exception( $product );
$product(WC_Product) (required)
Product object associated with the cart item.

Code of CartController::throw_default_product_exception() WC 5.8.0

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