Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives

Incentive::validate_incentive()protectedWC 1.0

Validate an incentive details.

It will check if the incentive details have the required keys.

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

Хуков нет.

Возвращает

true|false. Whether the incentive data is valid.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_incentive( $incentive ): bool;
$incentive(массив) (обязательный)
The incentive details.

Код Incentive::validate_incentive() WC 9.6.1

protected function validate_incentive( array $incentive ): bool {
	// The incentive must have an ID, a promo ID, and a type.
	$required_keys = array( 'id', 'promo_id', 'type' );
	foreach ( $required_keys as $key ) {
		if ( empty( $incentive[ $key ] ) ) {
			return false;
		}
	}

	return true;
}