Automattic\WooCommerce\Internal\Admin\Settings

SettingsUISchema::should_promote_to_integer │ private static │ WC 1.0

Whether a legacy number follows the HTML integer step contract.

Promotion happens only when the step is 1 and every quantity the integer path will later canonicalize — the stored value and the min/max bounds — is itself integral. A step=1 control holding a decimal value or bound (which the classic sanitizer never rejected) stays a 'number' field, so integer canonicalization does not throw and collapse the section into the fallback.

Method of the class: SettingsUISchema{}

No Hooks.

Returns

bool.

Usage

$result = SettingsUISchema::should_promote_to_integer( $field ): bool;
$field(array) (required)
Field definition.

SettingsUISchema::should_promote_to_integer() code WC 11.2.1

private static function should_promote_to_integer( array $field ): bool {
	$attributes = isset( $field['customAttributes'] ) && is_array( $field['customAttributes'] ) ? $field['customAttributes'] : array();
	if ( ! array_key_exists( 'step', $attributes ) || '1' !== self::get_integral_decimal( $attributes['step'] ) ) {
		return false;
	}

	$validation = isset( $field['validation'] ) && is_array( $field['validation'] ) ? $field['validation'] : array();
	$candidates = array(
		$field['value'] ?? null,
		$attributes['min'] ?? null,
		$attributes['max'] ?? null,
		$validation['min'] ?? null,
		$validation['max'] ?? null,
	);

	foreach ( $candidates as $candidate ) {
		if ( null === $candidate || ( is_string( $candidate ) && '' === trim( $candidate ) ) ) {
			// An absent or empty quantity imposes no integer constraint.
			continue;
		}
		if ( null === self::get_integral_decimal( $candidate ) ) {
			return false;
		}
	}

	return true;
}