WordPress at Your Fingertips
function is not described

WC_REST_Taxes_Controller::add_tax_rate_locales() protected WC 1.0

Add tax rate locales to the response array.

{} It's a method of the class: WC_REST_Taxes_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->add_tax_rate_locales( $data, $tax );
$data(array) (required)
Response data.
$tax(stdClass) (required)
Tax object.

Code of WC_REST_Taxes_Controller::add_tax_rate_locales() WC 5.7.0

protected function add_tax_rate_locales( $data, $tax ) {
	global $wpdb;

	$data              = parent::add_tax_rate_locales( $data, $tax );
	$data['postcodes'] = array();
	$data['cities']    = array();

	// Get locales from a tax rate.
	$locales = $wpdb->get_results(
		$wpdb->prepare(
			"
			SELECT location_code, location_type
			FROM {$wpdb->prefix}woocommerce_tax_rate_locations
			WHERE tax_rate_id = %d
			",
			$tax->tax_rate_id
		)
	);

	if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) {
		foreach ( $locales as $locale ) {
			if ( 'postcode' === $locale->location_type ) {
				$data['postcodes'][] = $locale->location_code;
			} elseif ( 'city' === $locale->location_type ) {
				$data['cities'][] = $locale->location_code;
			}
		}
	}

	return $data;
}