WordPress at Your Fingertips
function is not described

WC_REST_WCCOM_Site_Installer_Controller::validate_products() protected WC 3.7.0

Validate products from request body.

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

No Hooks.

Return

true|false|WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_products( $products );
$products(array) (required)
Array of products where key is product ID and element is install args.

Changelog

Since 3.7.0 Introduced.

Code of WC_REST_WCCOM_Site_Installer_Controller::validate_products() WC 5.8.0

protected function validate_products( $products ) {
	$err = new WP_Error( 'invalid_products', __( 'Invalid products in request body.', 'woocommerce' ), array( 'status' => 400 ) );

	if ( ! is_array( $products ) ) {
		return $err;
	}

	foreach ( $products as $product_id => $install_args ) {
		if ( ! absint( $product_id ) ) {
			return $err;
		}

		if ( empty( $install_args ) || ! is_array( $install_args ) ) {
			return $err;
		}
	}

	return true;
}