WC_Tax::_update_tax_rate_postcodes()public staticWC 2.3.0

Update postcodes for a tax rate in the DB.

Internal use only.

Method of the class: WC_Tax{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, $postcodes );
$tax_rate_id(int) (required)
Tax rate to update.
$postcodes(string) (required)
String of postcodes separated by ; characters.

Changelog

Since 2.3.0 Introduced.

WC_Tax::_update_tax_rate_postcodes() code WC 8.7.0

public static function _update_tax_rate_postcodes( $tax_rate_id, $postcodes ) {
	if ( ! is_array( $postcodes ) ) {
		$postcodes = explode( ';', $postcodes );
	}
	// No normalization - postcodes are matched against both normal and formatted versions to support wildcards.
	foreach ( $postcodes as $key => $postcode ) {
		$postcodes[ $key ] = strtoupper( trim( str_replace( chr( 226 ) . chr( 128 ) . chr( 166 ), '...', $postcode ) ) );
	}
	self::update_tax_rate_locations( $tax_rate_id, array_diff( array_filter( $postcodes ), array( '*' ) ), 'postcode' );
}