WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_Shipping_Legacy_Local_Pickup::is_valid_postcode() public WC 1.0

See if a given postcode matches valid postcodes.

{} Это метод класса: WC_Shipping_Legacy_Local_Pickup{}

Хуков нет.

Возвращает

true/false.

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

$WC_Shipping_Legacy_Local_Pickup = new WC_Shipping_Legacy_Local_Pickup();
$WC_Shipping_Legacy_Local_Pickup->is_valid_postcode( $postcode, $country );
$postcode(строка) (обязательный)
Postcode to check.
$country(строка) (обязательный)
code Code of the country to check postcode against.

Код WC_Shipping_Legacy_Local_Pickup::is_valid_postcode() WC 4.7.1

<?php
public function is_valid_postcode( $postcode, $country ) {
	$codes              = $this->get_valid_postcodes();
	$postcode           = $this->clean( $postcode );
	$formatted_postcode = wc_format_postcode( $postcode, $country );

	if ( in_array( $postcode, $codes, true ) || in_array( $formatted_postcode, $codes, true ) ) {
		return true;
	}

	// Pattern matching.
	foreach ( $codes as $c ) {
		$pattern = '/^' . str_replace( '_', '[0-9a-zA-Z]', preg_quote( $c ) ) . '$/i';
		if ( preg_match( $pattern, $postcode ) ) {
			return true;
		}
	}

	// Wildcard search.
	$wildcard_postcode = $formatted_postcode . '*';
	$postcode_length   = strlen( $formatted_postcode );

	for ( $i = 0; $i < $postcode_length; $i++ ) {
		if ( in_array( $wildcard_postcode, $codes, true ) ) {
			return true;
		}
		$wildcard_postcode = substr( $wildcard_postcode, 0, -2 ) . '*';
	}

	return false;
}