WC_REST_WCCOM_Site_Installer_Controller::validate_products( array $products )

Validate products from request body.


Description Description


Parameters Parameters

$products

(Required) Array of products where key is product ID and element is install args.


Top ↑

Return Return

(bool|WP_Error)


Top ↑

Source Source

File: includes/wccom-site/rest-api/endpoints/class-wc-rest-wccom-site-installer-controller.php

	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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.7.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.