Automattic\WooCommerce\StoreApi\Utilities

OrderController::normalize_location_field │ private static │ WC 1.0

Normalizes a location field the way shipping zones and tax rates match it.

Method of the class: OrderController{}

No Hooks.

Returns

string.

Usage

$result = OrderController::normalize_location_field( $field, $location ): string;
$field(string) (required)
Field name.
$location(array) (required)
Location the field belongs to.

OrderController::normalize_location_field() code WC 11.3.0

private static function normalize_location_field( string $field, array $location ): string {
	$value = (string) ( $location[ $field ] ?? '' );

	if ( 'postcode' === $field ) {
		return wc_normalize_postcode( $value );
	}

	// Both lookups use strtoupper(), which leaves multibyte characters alone, and the tax lookup does
	// not trim. Matching them keeps the check from treating two values as equal when a lookup would not.
	return strtoupper( $value );
}