Automattic\WooCommerce\Internal\Caches

ProductCache::validateprotectedWC 10.5.0

Validate an object before caching it.

Method of the class: ProductCache{}

No Hooks.

Returns

String[]|null. An array of error messages, or null if the object is valid.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate( $product ): ?array;
$product(WC_Product) (required)
The product to validate.

Changelog

Since 10.5.0 Introduced.

ProductCache::validate() code WC 10.8.1

protected function validate( $product ): ?array {
	if ( ! $product instanceof WC_Product ) {
		return array( 'The supplied product is not an instance of WC_Product' );
	}

	return null;
}